在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
这里只有一切基础的Demo,后期会继续更新的
let redView : UIView = UIView.init() redView.backgroundColor = UIColor.red self.view.addSubview(redView) redView.snp.makeConstraints { (make) in make.width.height.equalTo(50) //宽度和高度设置为50 make.center.equalTo(self.view)//在self.view上居中 }
let redView : UIView = UIView.init() redView.backgroundColor = UIColor.red self.view.addSubview(redView) redView.snp.makeConstraints { (make) in make.height.equalTo(50) make.top.equalTo(100) make.left.equalTo(10) make.right.equalTo(-10) }
let blue : UIView = UIView.init() blue.backgroundColor = UIColor.blue self.view.addSubview(blue) blue.snp.makeConstraints { (make) in make.top.equalTo(redView.snp.bottom) make.left.equalTo(redView.snp.left) make.width.equalTo((redView.snp.width)) make.height.equalTo((redView.snp.height)).multipliedBy(0.5) }
let blue : UIView = UIView.init() blue.backgroundColor = UIColor.blue self.view.addSubview(blue) blue.snp.makeConstraints { (make) in make.top.equalTo(redView.snp.bottom) make.left.equalTo(redView) make.width.equalTo((redView)) make.height.equalTo((redView)).multipliedBy(0.5) }
let blue : UIView = UIView.init() blue.backgroundColor = UIColor.blue self.view.addSubview(blue) blue.snp.makeConstraints { (make) in make.edges.equalTo(redView) }
let blue : UIView = UIView.init() blue.backgroundColor = UIColor.blue self.view.addSubview(blue) blue.snp.makeConstraints { (make) in make.edges.equalTo(self.view).inset(UIEdgeInsets.init(top: 10, left: 10, bottom: 10, right: 10)) }
let lab:UILabel = UILabel.init() lab.textAlignment = .center lab.backgroundColor = UIColor.red lab.numberOfLines = 0 lab.text = "我是一个UILabel" self.view.addSubview(lab) lab.snp.makeConstraints { (make) in make.center.equalTo(self.view) // make.width.greaterThanOrEqualTo(200)//最小的宽度是200 make.width.lessThanOrEqualTo(20)//最大的宽度是20 }
let lab:UILabel = UILabel.init() lab.textAlignment = .center lab.backgroundColor = UIColor.red lab.numberOfLines = 0 lab.text = "我是一个UILabel" self.view.addSubview(lab) lab.snp.makeConstraints { (make) in make.height.equalToSuperview().offset(-100) make.center.equalToSuperview() }
let lab:UILabel = UILabel.init() lab.textAlignment = .center lab.backgroundColor = UIColor.red lab.numberOfLines = 0 lab.text = "我是一个UILabel" self.view.addSubview(lab) lab.snp.makeConstraints { (make) in make.height.equalTo(redView).offset(50) make.center.equalToSuperview() }
|
请发表评论