1

I'm trying to change the text color in the status bar to match the rest of the apps appearance. I can change the text color in the nav bar for the MFMailComposeViewController easily enough:

myEmailComposerViewConotroller.navigationBar.tintColor = UIColor.whiteColor()

Am I missing something in the API on changing the text color of the status bar?

e_r
  • 794
  • 2
  • 8
  • 18

2 Answers2

0

From my understanding of your question, I think you're going to want to do something like this:

myEmailComposerViewConotroller.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]

titleTextAttributes is of type [NSObject: AnyObject]?

so that is why we initialize it to:

[NSForegroundColorAttributeName : UIColor.whiteColor()]
Justin Rose
  • 1,041
  • 7
  • 14
  • I'm actually looking to change the text color on the Status Bar, not the navigation bar. The snippet I posted above actually sets the navigation bar text tint to white including the cancel and send buttons. – e_r Jun 29 '15 at 00:36
0

I already answered sth similar here: how to change statusbar color in one view controller using swift?

Set View controller-based status bar appearance in your project.plist to NO

Subclass the MFMailViewController and implement custom viewWillAppear and viewWillDisappear functions

Use viewWillAppear and will viewWillDisappear to set and reset the statusBarStyle, while keeping a property with the previous statusBarStyle like this

let initialStatusBarStyle : UIStatusBarStyle

func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    initialStatusBarStyle = UIApplication.sharedApplication().statusBarStyle
    UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: animated)
}

func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    UIApplication.sharedApplication().setStatusBarStyle(initialStatusBarStyle, animated: animated)
}
Community
  • 1
  • 1
MarkHim
  • 5,686
  • 5
  • 32
  • 64