Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7

Managed to change the text color of the Send and Cancel buttons, which are on the UINavigationBar in the MFMailComposerViewController (both Send and Cancel) and MFMessageComposeViewController (only Cancel), when presented from UIActivityViewController.

Using an UIActivityViewController, tap on Messageor Mail:

Using an UIActivityViewController

You’ll notice that the default text color of the Send and Cancel buttons is blue:

Default blue colors

In order to change that, in the AppDelegate.m class, in the didFinishLaunchingWithOptions method, insert the following line:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];

This results in:

Changed to white

You can also use other colors, for example:

[UIColor purpleColor];

Change to purple

[UIColor greenColor];

Changed to green

How did I test this? I noticed this solution works for the following:

  • with Xcode 5.1, in the iOS 7.1 simulator, building as base iOS SDK 7.1 (can be chosen from selecting the project file -> Build Settings -> Base SDK. Also, selected from General -> Deployment Target -> 7.1)
  • with Xcode 5.1, on an iPhone 4, building as base iOS SDK 7.0 (can be chosen from selecting the project file -> Build Settings -> Base SDK. Also, selected from General -> Deployment Target -> 7.0)
  • with Xcode 5.1, on an iPhone 4, building as base iOS SDK 7.1 (can be chosen from selecting the project file -> Build Settings -> Base SDK. Also, selected from General -> Deployment Target -> 7.1)

It didn’t work when testing with:

  • with Xcode 5.1, in the iOS 7.0 simulator, building as base iOS SDK 7.0 (can be chosen from selecting the project file -> Build Settings -> Base SDK. Also, selected from General -> Deployment Target -> 7.0)

Therefore it should be safe to use, as I believe the behavior on the actual device matters more than the behavior in the iOS simulator.
If anyone knows why it doesn’t work in the iOS 7.0 simulator, I would like to know. 🙂

Leave a Comment