我创建了一个类别UINavigationBar的用下面的代码:的ObjectiveC类别不进口,但仍运行代码
// UINavigationBar+MyNavigationBar.m
@interface UINavigationBar (MyNavigationBar)
@end
@implementation UINavigationBar (MyNavigationBar)
- (void)drawRect:(CGRect)rect
{
UIImage *img = [UIImage imageNamed: @"header.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
我没有任何地方不过#进口,在任何代码在我的整个项目,此类别仍在运行并插入标题图形。这怎么可能?
'编译到您的应用中的任何类别都会在您的应用运行时随时加载。'很高兴知道,thx! – Philip007