选中/激活时,UIBarButtonItem粗体非标准字体

时间:2015-06-21 12:44:42

标签: swift ios8 uibarbuttonitem uiappearance

我想设置UIBarButtonItem,以便在我的应用中使用不同的字体。我正在使用appearance执行此操作,但是我遇到了如何在选中时以粗体显示字体的问题。这就是我想要做的事情:

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

有谁知道我怎么能做到这一点?字体绝对100%以粗体显示。

1 个答案:

答案 0 :(得分:0)

使文本变为粗体,这是一般语法:

customLabel.font = [UIFont boldSystemFontOfSize:16.0f]

但您可以简单地选择字体的粗体版 Apple SD Gothic Neo ,以下是列表:

  • AppleSDGothicNeo薄
  • AppleSDGothicNeo光强
  • AppleSDGothicNeo-Regular
  • AppleSDGothicNeo-Medium
  • AppleSDGothicNeo-SemiBold
  • AppleSDGothicNeo-Bold
  • AppleSDGothicNeo-Medium