每当我点击这个具有unicode标题的UIBarButtonItem来显示一个cog符号时,它会调整大小并变小。这是代码:
let settings = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(show_settings))
let font = UIFont.systemFont(ofSize: 28)
let attributes = [NSAttributedStringKey.font : font]
settings.setTitleTextAttributes(attributes, for: .normal)
答案 0 :(得分:1)
为突出显示的状态以及以下设置TitleAttribute:
let settings = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(show_settings))
let font = UIFont.systemFont(ofSize: 28)
let attributes = [NSAttributedStringKey.font : font]
settings.setTitleTextAttributes(attributes, for: .normal)
settings.setTitleTextAttributes(attributes, for: .highlighted)
希望这会对你有所帮助:)。
答案 1 :(得分:0)
您可以在此处为正常状态
设置属性settings.setTitleTextAttributes(attributes, for: .normal)
答案 2 :(得分:0)
试试这个
settings.titleLabel.font = [UIFont systemFontOfSize: 28];
或Swift
settings.titleLabel?.font = UIFont.systemFont(ofSize: 28)
我认为问题在于你正常使用这个属性,而当你点击它时,max是默认大小会覆盖它。我不确定,但上面的一行应该有用
答案 3 :(得分:0)
试试这个,
settings.setTitleTextAttributes(
[
NSAttributedStringKey.font :UIFont.systemFont(ofSize: 28) ,
NSAttributedStringKey.foregroundColor : UIColor.blue
],
for: .normal)