【发布时间】:2015-08-11 13:56:07
【问题描述】:
我想知道如何更改 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()
}
}
【问题讨论】:
标签: ios swift uibarbuttonitem