MFMailComposeViewController bar background color not changing in iOS7

前端 未结 9 1443
情歌与酒
情歌与酒 2020-12-31 00:32

I\'m trying to change the background color of the MFMailComposeViewController in iOS7 but I cannot make it work.

I\'m

相关标签:
9条回答
  • 2020-12-31 00:52

    For iOS8:

    NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                                [UIColor whiteColor],UITextAttributeTextColor, 
                                                [UIColor blackColor], UITextAttributeTextShadowColor, 
                                                [NSValue valueWithUIOffset:UIOffsetMake(-1, 0)], UITextAttributeTextShadowOffset, nil];
    
    [[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
    

    Or

    navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:UITextAttributeTextColor];
    
    0 讨论(0)
  • 2020-12-31 00:52

    @SoftDesigner's answer:

    As of iOS 9:

    [UINavigationBar appearance].tintColor = yourFavoriteColor;
    

    does not work on the MFMailComposeViewController.

    The rest of the answer works (I used it), but as far as I can tell you're stuck with Apple's colors for the nav bar buttons.

    Hope this saves someone else some angst.

    0 讨论(0)
  • 2020-12-31 00:57

    I had a problem that prevented me from setting the background colour. Turns out I had some other code elsewhere setting the background image to [UIImage new].

    The following code fixed it:

     [[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
     [[UINavigationBar appearance] setShadowImage:nil];
    
    0 讨论(0)
  • 2020-12-31 00:58

    try this. worked for me.

    MFMailComposeViewController* myailViewController = [[MFMailComposeViewController alloc] init];
    // set other attributes of mailcomposer here.
    myMailViewController.mailComposeDelegate = self;
    
    [myMailViewController.navigationBar setTintColor:[UIColor whiteColor]];
    
    [self presentViewController:myMmailViewController animated:YES completion:nil];
    
    0 讨论(0)
  • 2020-12-31 01:01

    Try the following code

        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
        [[UINavigationBar appearance] setBackgroundColor:[UIColor blackColor]];
    
        // Your usual code follows here ......
    
    0 讨论(0)
  • 2020-12-31 01:06

    The trick here is to call 'appearance methods' such as

    [UINavigationBar appearance].barTintColor = [UIColor whiteColor];
    [UINavigationBar appearance].tintColor = [UIColor redColor];
    

    BEFORE calling to

    [[MFMailComposeViewController alloc] init];
    

    This way the color scheme will be applied to the mail composer. It may be returned back to defaults in mailComposeController:didFinishWithResult:

    0 讨论(0)
提交回复
热议问题