ios - 删除电子邮件表上的自定义导航栏

标签 ios objective-c uinavigationbar mfmailcomposeviewcontroller

我的 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/

相关文章:

ios - 使用 XCode 7 运行单元测试目标时崩溃

ios - 使用其他参数上传 Alamofire 4 和 Swift 3 图片

ios - NSNotificationCenter 在 ViewController 之间不工作

ios - 强制 ui 导航 Controller 仅纵向

ios - iPad iOS 6 如何防止顶角 UINavigationBar 与背景图像四舍五入

ios - 只播放一次声音,条件

ios - 企业iOS : will adding an existing bundle ID to an app group invalidate already deployed apps?

iphone - 计算给定宽度和字体大小的行数

html - 如何在一段 NSAttributedString 周围制作一个框

ios - 具有多种颜色的大型导航栏文本