MFMailComposeViewController Bar titleText and UIbarbuttons not using custom font provided by appearance proxy
Asked Answered
I

1

7

I have changed the appearance of UIBarButtonItem and UINavigationBar titleTextAttributes to my custom Font along with color to white using Appearance Proxy in "applicationDidFinishLaunching". Every navigation title texts and BarButtonItems are using custom font provided.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    application.setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
    UINavigationBar.appearance().barStyle = UIBarStyle.BlackTranslucent
    UINavigationBar.appearance().barTintColor = NSFontAttributeName:SharedHelper.myCustomBarColor()
    UINavigationBar.appearance().titleTextAttributes =[NSForegroundColorAttributeName:UIColor.whiteColor()]

    UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()
    let attributes = [NSFontAttributeName:SharedHelper.customFontForBarButton()]
    UIBarButtonItem.appearance().setTitleTextAttributes(attributes, forState: UIControlState.Normal)
    return true
}    

The problem comes when I use MFMailComposeViewController for sending email. The MFMailComposeViewController ignores the Font Attributes and reverted back to default fonts. In iPhone 5S simulator, I can see the custom font for a while but it reverts back to default one.

enter image description here

Shown for a while in iPhone Simulator 5S. ( I am trying to accomplish this )

enter image description here

Uses default font after few seconds.

Any help on this? Shouldn't the appearance proxy work for UIBarButton & NavigationBar of MFMailComposeViewController too or is there need of any coding for this?

I am using Swift and also tried using appearanceWhenContainedIn by Alexander using Bridge but didn't seems to work. My concern is to change the font of titleText and BarButtonItems ( cancel, send ) of MFMailComposeViewController.

Thanks in advance. Any help would be highly appreciated.

Illbred answered 7/9, 2015 at 5:39 Comment(2)
HI, I'm having the same issue, did you find a workaround?Gates
@HugoAlonso: Nope I ended up using default font.Illbred
A
0

I've been battling the same issue with iOS 9 devices for the past few days. I've tried just about everything. However, this morning I will attempt to add the following to the AppDelegate:

UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([MFComposeViewController.self]).setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blueColor()], forState: .Normal)

I can't use UINavigationBar class since it would effect the whole app appearance and that's not what I want.

I'll post back if it works.

Apocalyptic answered 9/9, 2016 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.