When I'm using a UIActivityViewController
, after the user chooses an activity (such as Mail or Message), I can not change the text color for the status bar nor the text/tint color of the Cancel and Send navigation bar buttons. For the bar buttons, in the AppDelegate
I've tried using:
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
And nothing happens. However I am able to set the navigation bar title with this:
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil]];
I set the UIViewControllerBasedStatusBarAppearance
to NO
in the Info.plist
. And put the line:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
in the AppDelegate
, and have had no luck changing the status bar color at all. Any ideas?
Rather than sub-classing from
UIActivityViewController
, we can change the tintColor of the navigation bar upon presenting it and revert it upon completion in thecompletionHandler
. For example:As the UIActivityViewController presents the underlying model view controllers, we use this workaround to fix the status bar color issue:
As you can see, this is just a class extending the UIActivityViewController overriding the
presentViewController:animated:completion:
. When the view controller has been presented we set the status bar style via UIApplication in the completion block. Then we call the original completion block given to the method, if any.I found a solution to change the text color of the Send and Cancel buttons.
Check my answer from here.
Regarding changing the status bar style from black to white, I've tried pretty much everything that is on Stackoverflow and nothing worked. There seems to be no workaround it.
One thing that might work, but I don't really know how to use it, could be changing the status bar style in the child view controller. There's a Stackoverflow post about it here.
This might work only if the assumption that the
MFMailComposerViewController
andMFMessageComposeViewController
are child view controllers ofUIActivityViewController
and therefore if we specify the status bar style for theUIActivityViewController
then the child view controllers should have the same status bar style as the parent.There's a method in the
UIViewController
calledchildViewControllerForStatusBarStyle
. Here is the Apple documentation for it .But I don't really know how to use that. Did anyone figure this out?
I believe the code to change the navigation bar color is this:
This is for changing the colours of the navigation bar buttons in iOS 7, if you might need it:
And this is the code if you want to change the colours of the buttons in iOS 6:
This code is also for iOS 8+ to change the bar button text color for UIActivityViewController activities (like sharing via Messages or Mail Composer).
You have to set the tintColor of the entire app.
or
bar buttons
In iOS 8 the UIActivityViewController presents its individual compose controllers on the root view controller of your application.
You need to subclass your root view controller (whether it be a UIViewController or UINavigationController) and add the following code.
and then instead of initializing a UINavigationController in the AppDelegate or storyboard, initialize your newly subclassed controller.
Some other recommendations subclass the UIActivityViewController but this does not work.
If you want to change the bar button and title colors as well use the following in your application:didFinishLaunching: