Reputation: 5929
I have customize my UINavigationBar with UINavigationBar drawRect and it is working fine until I fire up MFMailComposeViewController, which gives me a trouble as I couldn't override UIBarButton for the mail class, it create akward view like below:
While I try to prevent the MFMailComposeViewController
and produce code below for using the default drawRect for MFMailComposeViewController
, it even worse it create a black UIBar
:
The Code:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
//Prevent Mail Controller For Customizing NavigationBar
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder* nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[MFMailComposeViewController class]]) {
[super drawRect:rect];
return;
}
}
UIImage *image = [UIImage imageNamed: @"titleBar.png"];
[image drawInRect:CGRectMake(0, 0, 320, 44)];
}
@end
What I am trying to do here is to make sure MFMailComposeViewController
having the same style of UINavigationBar
and UIButtonItem
. It can be either way:
1) Both UINavigationBar
and UIButtonItem
have customized background
2) Default UINavigationBar
style (gradient blue)
Would like to know can I achieve this? Thanks in advance.
Upvotes: 1
Views: 1163
Reputation: 5929
After some hacking and testing, still not manage to customize the button. But this is the closest I can get, by setting the tint color of mail controller.
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
mailController.navigationBar.tintColor = [UIColor brownColor];
Upvotes: 1