WKInterfaceLabel
1.1-簡介
- WKInterfaceLabel與iOS的UIKit框架中UILabel一樣,是一個顯示文本的控件涌矢。
1.2-API介紹
- WKInterfaceLabel的API比UILabel要簡單的多吹零。
//設(shè)置文本
public func setText(text: String?)
//設(shè)置文本顏色
public func setTextColor(color: UIColor?)
//設(shè)置富文本
public func setAttributedText(attributedText: NSAttributedString?)
1.3-使用示例
/* 設(shè)置文本 */
topLabel.setText("heima")
/* 設(shè)置文本顏色 */
bottomLabel.setTextColor(UIColor.greenColor())
/* 設(shè)置富文本 */
//先初始化一個AttributedString
let attribute = NSMutableAttributedString(string: "itcast")
//添加屬性
attribute.addAttributes([NSFontAttributeName:UIFont.systemFontOfSize(20),NSForegroundColorAttributeName:UIColor.redColor()], range: NSMakeRange(0, 2))
bottomLabel.setAttributedText(attribute)
- 效果
0701.png