//创建Label
var label = UILabel(frame:CGRectMake(20,100,30))
label.text = "labelfwade"
//背景颜色和文字颜色的设置
label.textColor = UIColor.blueColor()
label.backgroundColor = UIColor.redColor()
//对齐方式的设置
label.textAlignment = NSTextAlignment.Right
label.shadowColor = UIColor.brownColor()
label.shadowOffset = CGSizeMake(-5,-5)
label.font = UIFont(name:"",size: 20)
//文字过长时的省略方式
label.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle
label.adjustsFontSizeToFitWidth = true;
label.numberOfLines = 0;
label.highlighted = true
label.highlightedTextColor = UIColor.purpleColor()
var attributeString = NSMutableAttributedString(string:"hello,world")
attributeString.addAttribute(NSFontAttributeName,value: UIFont(name: "HelveticaNeue-Bold",size: 10)!,range: NSMakeRange(0,5))
attributeString.addAttribute(NSForegroundColorAttributeName,value: UIColor.blueColor(),5))
attributeString.addAttribute(NSBackgroundColorAttributeName,value: UIColor.greenColor(),range: NSMakeRange(3,3))
label.attributedText = attributeString
self.view.addSubview(label)