我为barButtonItem,UIColor,Custom Font设置了setTitleTextAttributes。当我点击barButton时,在我持有barButton的那段时间,字体更改为系统一,在我放开barButton后它返回到自定义字体。我不使用tintColor设置。为什么会这样?
愿有人帮帮我吗?
这是我设置属性的方式:
@IBOutlet weak var saveBarButton: UIBarButtonItem! {
didSet {
saveBarButton.title = "SAVE"
saveBarButton.setTitleTextAttributes([NSAttributedString.Key.font:
UIFont.textStyle5], for: .normal)
}
}
我使用自定义UIFont。提前致谢。
您还需要为突出显示的状态设置相同的字体:
saveBarButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.textStyle5], for: .highlighted)