import UIKit
class ViewController: UIViewController ,UITextFieldDelegate,UITextViewDelegate,UIActionSheet Delegate,UIAlertViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()
//UILabel的創(chuàng)建
let label:UILabel = UILabel()
//設(shè)置frame大小
label.frame = CGRectMake(10, 40, 200, 30)
label.backgroundColor = UIColor.grayColor()
label.text = "www.baidu.com"
label.textColor = UIColor.redColor()
//設(shè)置文字對齊方式
label.textAlignment = NSTextAlignment.Center
//設(shè)置陰影顏色
label.shadowColor = UIColor.blackColor()
//設(shè)置陰影大小
label.shadowOffset = CGSizeMake(-5, 5)
label.font = UIFont(name: "Zapfino", size: 20)
//文字過長時省略形式
label.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle
//文字大小自適應(yīng)標(biāo)簽寬度
label.adjustsFontSizeToFitWidth = true
//顯示文字行數(shù)設(shè)置(默認(rèn)顯示是1行)
label.numberOfLines = 0
//設(shè)置文本高亮
label.highlighted = true
//設(shè)置文本高亮顏色
label.highlightedTextColor = UIColor.greenColor()
//富文本設(shè)置
// var attributeString =NSMutableAttributedString(string: "www.cometoqingdao")
// attributeString.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Bold", size: 16)!, range: NSMakeRange(0,6))
// attributeString.addAttribute(NSForegroundColorAttributeName, value: UIColor.whiteColor(), range: NSMakeRange(0, 3))
// attributeString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.blueColor(), range: NSMakeRange(3, 3))
// label.attributedText = attributeString
self.view.addSubview(label)
}
}