Upto iOS 10, the font for disabled and enabled uibarbuttonitem remains same, only color differs. But, after i installed my app on device having ios 11, the font for disabled mode get updated(showing system font), whereas in enabled mode it is showing the proper font which i set.
So, for case of iOS 11, How can i set font for disabled mode to keep consistency in the app.
This appears to have changed in iOS 11, at least in my case where I'm using the UIAppearance protocol. Not sure if this is a bug or intentional.
I also found I couldn't mask values together (such as .normal|.disabled
) as it meant it would only apply the font if the control satisfied all states.
So I ended up doing this:
for controlState in [UIControlState.normal, UIControlState.disabled, UIControlState.focused, UIControlState.highlighted, UIControlState.selected] {
barButton.setTitleTextAttributes([NSFontAttributeName: customFontName], for: controlState)
}
For updating it everywhere using the UIAppearance protocol:
for controlState in [UIControlState.normal, UIControlState.disabled, UIControlState.focused, UIControlState.highlighted, UIControlState.selected] {
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: customFontName, for: controlState);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With