Swfit:控件屬性備注

設(shè)置文字

visitorButton.setTitle("注冊", forState: UIControlState.Normal)

設(shè)置字體顏色

    visitorButton.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
    visitorButton.setTitleColor(UIColor.grayColor(), forState: UIControlState.Highlighted)

設(shè)置字體大小

visitorButton.titleLabel!.font = UIFont.systemFontOfSize(16);

另一種方式設(shè)置

  //行間距
    let content = "content"
     
    let attributedString = NSMutableAttributedString.init(string: content)
     
    let paragraphStyle = NSMutableParagraphStyle()
     
    paragraphStyle.lineSpacing = 10
     
    attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, content.characters.count))
     
    label.attributedText = attributedString

    //字體顏色
    let attributedString = NSMutableAttributedString(string: self.integralLabel.text!)

    let color = UIColor.redColor()

    let normalAttributes = [NSForegroundColorAttributeName : color]

    attributedString.addAttributes(normalAttributes, range: NSMakeRange(0,2))

    self.integralLabel.attributedText = attributedString

    //字體大小 和顏色
    let attributedString = NSMutableAttributedString(string: self.newRanking.text!)
     
    let color = UIColor.redColor()
     
    let normalAttributes = [NSForegroundColorAttributeName : color,NSFontAttributeName:UIFont.boldSystemFontOfSize(20)]
     
    attributedString.addAttributes(normalAttributes, range: NSMakeRange(5,2))
     
    self.newRanking.attributedText = attributedString
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容