SnapKit代码约束

        let label = UILabel()
        label.frame = CGRectMake(100, 100, 100, 100)
        label.backgroundColor = UIColor.cyanColor()
        label.text = "SnapKit"
        label.textAlignment = NSTextAlignment.Center
        self.view.addSubview(label)
        label.snp_makeConstraints { (make) in
            
            make.height.width.equalTo(100)
            make.top.equalTo(self.view.snp_top).offset(50)
            make.centerX.equalTo(self.view.snp_centerX)
        }
        let label1 = UILabel()
        label1.frame = CGRectMake(100, 100, 100, 100)
        label1.backgroundColor = UIColor.cyanColor()
        label1.text = "SnapKit"
        label1.textAlignment = NSTextAlignment.Center
        self.view.addSubview(label1)
        label1.snp_makeConstraints { (make) in
            
            make.height.width.equalTo(100)
            make.top.equalTo(label.snp_bottom).offset(50)
            make.centerX.equalTo(self.view.snp_centerX)
        }

 

 

posted @ 2016-08-17 14:21  代码始我快乐  阅读(301)  评论(0编辑  收藏  举报