标签:
Swift_UI_UILabel
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // 1.创建label var swiftLabel : UILabel = UILabel(frame: CGRectMake(50, 100, 150, 30)) // 2.设置label的内容 swiftLabel.text = "swiftLablel" // 3.设置label内容的颜色 swiftLabel.textColor = UIColor.blueColor() // 4.设置label的背景颜色 swiftLabel.backgroundColor = UIColor.greenColor() // 5.切圆角 swiftLabel.layer.cornerRadius = 15 swiftLabel.layer.masksToBounds = true // 6.设置居中 swiftLabel.textAlignment = NSTextAlignment.Center; // 7.设置字的大小 swiftLabel.font = UIFont.systemFontOfSize(10) // 8. 设置断行模式,单词断行 swiftLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping // 9.设置行数,设置为0,如果文本框有足够的显示会全部显示 swiftLabel.numberOfLines = 0 // 10.将label加入到view self.view.addSubview(swiftLabel) } }
标签:
原文地址:http://www.cnblogs.com/advacedprogrammer/p/4294988.html