Below code works on iOS version 9.x or less, for some reason this does not work if iOS 10
if([MFMessageComposeViewController canSendText])
{
Prior to iOS 10, I was using the appearance proxy for UINavigationBar
, something like this:
NSDictionary* titleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourNavBarTitle,
NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };
[[UINavigationBar appearance] setBarTintColor:[ColoursAndStyles sharedInstance].viewColourNavBarMain];
[[UINavigationBar appearance] setTintColor:[ColoursAndStyles sharedInstance].viewColourNavBarTint];
[[UINavigationBar appearance] setTitleTextAttributes:titleAttribs];
This covered my use of MFMessageComposeViewController
, with setTitleTextAttributes
taking care of the text colour of the title/caption.
With iOS 10, I'm using the following work around. Just before I present the MFMessageComposeViewController
, I change the title text attributes. E.g.:
- (void)sendTap:(id)s
{
// some code...
NSDictionary* newTitleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourTitleStrip,
NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };
[[UINavigationBar appearance] setTitleTextAttributes:newTitleAttribs];
// present the MFMessageComposeViewController...
}
And then set things back to how I want them for the rest of the app, when the MFMessageComposeViewController
finishes, e.g.:
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
NSDictionary* titleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourNavBarTitle,
NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };
[[UINavigationBar appearance] setTitleTextAttributes:titleAttribs];
// some code...
[controller dismissViewControllerAnimated:YES completion:^{
// some code...
}];
}