gpt4 book ai didi

ios - 更改 UIBarButtonItem 文本字体大小和颜色

转载 作者:搜寻专家 更新时间:2023-10-30 22:05:10 26 4
gpt4 key购买 nike

我想知道如何更改 BarButtonItem 的文本字体?虽然我无法设置 setTitleTextAttributes

class TextfieldLogin : UITextField {

func INIT(){
let numberToolbar = UIToolbar(frame: CGRectMake(0,0,320,50))
numberToolbar.tintColor = UIColor.whiteColor()
numberToolbar.barTintColor = UIColor(red: 155.0/255, green: 14.0/255, blue: 45.0/255, alpha: 1.0)

numberToolbar.items = [
UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "DONE", style: UIBarButtonItemStyle.Plain, target: self, action: "close"),
UIBarButtonItem.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(18.0),NSForegroundColorAttributeName : UIColor.redColor(),NSBackgroundColorAttributeName:UIColor.blackColor()],
forState: UIControlState.Normal) ]

numberToolbar.sizeToFit()

}
}

最佳答案

这是你要找的吗?

objective-C :

[buttonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
[UIFont fontWithName:@"Helvetica-Bold" size:20.0], NSFontAttributeName,
[UIColor blackColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];

swift :

let titleDict: NSDictionary = [NSFontAttributeName: "Helvetica-Bold"]
self.numberToolbar.titleTextAttributes = titleDict

关于ios - 更改 UIBarButtonItem 文本字体大小和颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31943815/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com