func setupUI() {
let grayView = UIView()
grayView.backgroundColor = UIColor.gray
self.addSubview(grayView)
grayView.snp.makeConstraints { (make) in
make.top.equalTo(self).offset(5)
make.left.equalTo(self).offset(8)
make.bottom.equalTo(self).offset(-20)
make.width.equalTo(5)
}
let taskNameL = UILabel()
taskNameL.text = "恒泰开户"
taskNameL.font = UIFont.systemFont(ofSize: 14)
self.addSubview(taskNameL)
taskNameL.snp.makeConstraints { (make) in
make.top.equalTo(self).offset(5)
make.left.equalTo(self).offset(20)
make.width.equalTo(100)
make.height.equalTo(70)
}
let priceL = UILabel()
priceL.text = "¥ 20"
priceL.font = UIFont.systemFont(ofSize: 20)
self.addSubview(priceL)
priceL.snp.makeConstraints { (make) in
make.top.equalTo(self).offset(50)
make.left.equalTo(self).offset(20)
make.width.equalTo(100)
make.height.equalTo(70)
}
let dateL = UILabel()
dateL.text = "2017.09.13 - 2017.03.30"
dateL.font = UIFont.systemFont(ofSize: 14)
self.addSubview(dateL)
dateL.snp.makeConstraints { (make) in
make.bottom.equalTo(self).offset(-15)
make.left.equalTo(self).offset(20)
make.width.equalTo(300)
make.height.equalTo(15)
}
let button:UIButton = UIButton(type:.custom)
button.setTitle("查看详情>>", for:.normal) //普通状态下的文字
button.titleLabel?.font = UIFont.systemFont(ofSize: 11)
button.setTitleColor(UIColor.blue, for: .normal) //普通状态下文字的颜色
button.addTarget(self, action: #selector(push), for: .touchUpInside)
self.addSubview(button)
button.snp.makeConstraints { (make) in
make.bottom.equalTo(self).offset(-15)
make.right.equalTo(self).offset(-20)
make.width.equalTo(100)
make.height.equalTo(40)
}
}
swift snp布局
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Swift-UICollectionView布局之线性布局 应用场景 轮播图(AppStore) 数据展示(招商银...
- 瀑布流 UICollectionView Swift 最近整理以前iOS开发中用到的功能代码,发觉对瀑布流的布局有...
- 小编就会蒙人,只听过“许三多”和“三好学生”,哪来的“三少”和“三好”,没错!BETTER的第114次会议就有三少...