我的 App Delegate 中有这段代码:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"Nav Bar.png"] forBarMetrics:UIBarMetricsDefault];
这很好用,但我使用
MFMailComposeViewController
我希望它具有默认的 NavigationBar 外观。我怎么做?
编辑:
我试过这段代码:
[[UINavigationBar appearanceWhenContainedIn: [MFMailComposeViewController class], [UIViewController class], nil] setBackgroundImage:[UIImage imageNamed:@"Textured Background.png"] forBarMetrics:UIBarMetricsDefault];
我也试过只有这个代码。没有什么变化。默认导航栏,包括邮件 View Controller 。
我认为这可能与
appearanceWhenContainedIn:
有关.有谁知道MFMailComposeViewController
会包含在?
最佳答案
我想到了!这是代码:
[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
MFMailComposeViewController *emailVC = [[MFMailComposeViewController alloc] init];
//the rest of the implementation goes here...
[self presentViewController:emailVC animated:YES completion:nil];
然后,我在这里将导航栏外观设置为正常:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"Nav Bar.png"] forBarMetrics:UIBarMetricsDefault];
[self dismissViewControllerAnimated:YES completion:nil];
}
关于ios - 删除电子邮件表上的自定义导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18092930/