override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
/**
创建一个 label
*/
creatLabel()
}
func creatLabel() {
let label = UILabel(frame:CGRectMake(10,20,200,200))
self.view.addSubview(label)
label.snp_makeConstraints { (make) in
make.left.equalTo(10)
make.right.equalTo(-10)
make.top.equalTo(30)
}
label.text = "开始学习 swift"
label.textColor = UIColor.redColor()
label.backgroundColor = UIColor.brownColor()
label.textAlignment = NSTextAlignment.Center
label.font = UIFont.boldSystemFontOfSize(15)
label.layer.cornerRadius = 5.0
label.layer.masksToBounds = true
}
网友评论