开发者

category override on navbar not working

开发者 https://www.devze.com 2023-04-05 22:44 出处:网络
I use a category to override the uiNavBar and show an image in the bar @implementation UINavigationBar (CustomImage)

I use a category to override the uiNavBar and show an image in the bar

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CG开发者_JAVA百科Rect)rect {
UIImage *image = [UIImage imageNamed: @"navbarImg.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

at my root view controller. It works fine...

but now I have a tab bar with nav bar application, and it doesn't work now to show the image; I place the same "category" at the end of my root VC for that tab, and it doesn't show??

how to fix this please ???


A common practice for categories is to place the category in it's own .h file, and import it at the top of each file you'd like to use it in. That will probably fix your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消