I am trying to change the colour of the navigation bar buttons, navigation bar tint colour and text colour, however I don't seem to be getting anywhere. The MFMailComposeViewController
is being activated via a UIActivityViewController
and I have tried a few different methods that have worked before (not through a UIActivityViewController
though).
This is my current code:
UINavigationBar.my_appearanceWhenContainedIn(MFMailComposeViewController).barTintColor = UIColor.blackColor()
This was suggested here. I have also tried this:
activityVC.navigationController?.navigationBar.tintColor = UIColorFromRGB(0x0096FF)
activityVC.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
I'm also looking to change the status bar colour.
Anyone have any ideas?
UPDATE:
I fixed the navigation bar issues for the buttons and title, but still looking for a solution to the status bar. Doing this doesn't work:
self.presentViewController(activityVC, animated: true, completion: { () in
UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)
})
You can subclass the MFMailViewController
and override its viewWillAppear
method
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
self.navigationController.navigationBar.translucent = false
self.navigationController.navigationBar.opaque = false
self.navigationController.navigationBar.barTintColor = UIColor.blueColor()
}
Since you only want the status bar to be lightcontent
when the MFMailComposeViewController is active, you shouldn't put the
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
into your app delegates didFinishLoading. This would set it lightContent for your whole application.
for iOS8 you use barTintColor to change the color of status
NSString *invitationText = @"test";
[UINavigationBar appearance].barTintColor = [UIColor whiteColor];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:@"Test "];
[mc setMessageBody:invitationText isHTML:YES];
[self presentViewController:mc animated:YES completion:NULL];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With