@IBDesignable class AttributedBarButtonItem: UIBarButtonItem {
@IBInspectable var fontSize: CGFloat = 22 {
didSet {
let attributes: [String: AnyObject] = [NSFontAttributeName: UIFont(name: "Icomoon", size: fontSize)!]
setTitleTextAttributes(attributes, forState: .Normal)
}
}
}
这是属性检查器
中的样子但它没有改变任何东西:
答案 0 :(得分:4)
UIKeyboardWillShowNotification
无法与frame
一起使用,因为setScale
仅适用于BigDecimal(19.1234).setScale(2, BigDecimal.RoundingMode.DOWN)
=> res: scala.math.BigDecimal = 19.12
个子类(在iOS上),@IBDesignable
不是UIBarButtonItem
子类。
答案 1 :(得分:1)
只能通过UINavigationBar
:
@IBDesignable class AttributedNavigationBar: UINavigationBar {
@IBInspectable var transparentBackground: Bool = false {
didSet {
setBackgroundImage(transparentBackground ? UIImage() : nil, forBarMetrics: .Default)
shadowImage = transparentBackground ? UIImage() : nil
}
}
@IBInspectable var fontSize: CGFloat = 18
@IBInspectable var icomoonLeftBarButtonItems: Bool = false {
didSet {
let attributes = [NSFontAttributeName: UIFont(name: "Icomoon", size: fontSize)!]
if let leftBarButtonItems = topItem?.leftBarButtonItems {
for leftBarButtonItem in leftBarButtonItems {
leftBarButtonItem.setTitleTextAttributes(icomoonLeftBarButtonItems ? attributes : nil, forState: .Normal)
}
}
}
}
}
像魅力一样。
答案 2 :(得分:0)
试试这个:
fn-SubString