Reputation: 991
i am facing a new problem.
I have custom navigation controller in my application. I have to add an image to navigationbar and i used this code in my AppDelegate-
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"top-red.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, 44)];
}
@end.
This code is working fine for me, but when i use MFMailComposer in my application and call it on a button event i see that the navigationbar of MFMailcomposer is also changed to my custom navigationbar which i don't want to change.
Any Ideas!!!
Upvotes: 0
Views: 407
Reputation: 150605
By adding a category to the UINavigationBar, you are adding a method to all instances of UINavigationBar.
Since you are overriding drawRect:
that means that whenever any navigation bar wants to draw itself it is using your method rather than the standard drawRect:
Rather than do this, you should just add the image to your navigation bars where you want them , rather than change it globally as you have done here.
Upvotes: 3