0

ViewController有一个navigationBarwith Promt 并且在它之上我添加了一个自定义图像:

- (void)changeNavBar
{
    UIImage *image = [UIImage imageNamed: @"logo_home.png"];
    imageView = [[UIImageView alloc] initWithImage:image];
    imageView.contentMode = UIViewContentModeLeft;

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault];

    imageView.frame = CGRectMake(0, 0, 320, 70);

    [self.navigationController.navigationBar insertSubview:imageView atIndex:0];

    self.navigationController.navigationBar.backItem.backBarButtonItem.tintColor = [UIColor blackColor];
}

但是当用户单击“发送电子邮件”按钮时,我MFMailComposeViewController会以模态方式创建并呈现它。

- (IBAction)emailPressed:(id)sender
{
    NSString *emailTitle = event.title;
    NSString *messageBody = [NSString stringWithFormat:@"%@ - %@", event.title, event.concertUrl.absoluteString];

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];

    mc.mailComposeDelegate = self;
    NSLog(@"subviews: %d", mc.navigationBar.subviews.count);

    [mc setSubject:emailTitle];
    [mc setMessageBody:messageBody isHTML:NO];

    // Present mail view controller on screen
    [self presentModalViewController:mc animated:YES];
}

MFMailComposeViewController的导航栏在没有提示的情况下自动调整为普通导航栏,但我以前 VC 中的自定义图像不会消失。如何删除它并将标准黑色样式设置为我的 navigationBar ?

4

1 回答 1

2

您已经使用 UIAppearance 代理设置了背景图像,这将对应用程序中的每个导航栏产生影响。

改变

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault];

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"logo_home.png"] forBarMetrics:UIBarMetricsDefault];
于 2012-11-30T14:52:14.663 回答