Swift 初次使用 SnapKit

2016-05-17  本文已影响102人  马爷
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
}
上一篇下一篇

猜你喜欢

热点阅读