我为 barButtonItem、UIColor、自定义字体设置了 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)
关于ios - 快速点击条形按钮项目时 UIFont 发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55131534/