点击条形按钮项目时,UIFont会发生变化

问题描述 投票:0回答:1

我为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。提前致谢。

ios swift uibarbuttonitem
1个回答
1
投票

您还需要为突出显示的状态设置相同的字体:

saveBarButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.textStyle5], for: .highlighted) 
© www.soinside.com 2019 - 2024. All rights reserved.