UIBarButtonItem bold non-standard font when selected/active

476 views Asked by At

I want to setup UIBarButtonItem so that it uses a different font throughout my app. I'm doing this using appearance, however I have hit an issue with how to display the font in bold when its selected. Here is what I want to do:

var barButtonItemApperance = UIBarButtonItem.appearance()
barButtonItemApperance.setTitleTextAttributes([NSFontAttributeName : UIFont(name: "Apple SD Gothic Neo", size: 16)!], forState: UIControlState.Normal)
barButtonItemApperance.setTitleTextAttributes([NSFontAttributeName : UIFont(name: "Apple SD Gothic Neo", size: 16)!], forState: UIControlState.Selected) // I want this to be in bold text

Does anyone know how I can achieve this? The font is definitely 100% available in bold.

1

There are 1 answers

0
Himanshu gupta On

for making text bold, this is the general syntax:

customLabel.font = [UIFont boldSystemFontOfSize:16.0f]

But you can simply choose the bold version of the font Apple SD Gothic Neo, Below is the list:


  • AppleSDGothicNeo-Thin
  • AppleSDGothicNeo-Light
  • AppleSDGothicNeo-Regular
  • AppleSDGothicNeo-Medium
  • AppleSDGothicNeo-SemiBold
  • AppleSDGothicNeo-Bold
  • AppleSDGothicNeo-Medium