iOS-Masonry用法
2024-08-26 04:28:32
__weak typeof(self) weakSelf = self; UIView * tempView = [[UIView alloc]init];
NSInteger count = ;//设置一排view的个数
NSInteger margin = ;//设置相隔距离
NSInteger height = ;//设置view的高度
for (int i = ; i < count; i ++) {
UIView * view = [[UIView alloc]init];
view.backgroundColor = [UIColor brownColor];
[self.view addSubview:view];
if (i == ) {
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(weakSelf.view).offset(margin);
make.centerY.equalTo(weakSelf.view);
make.height.mas_equalTo(height);
}];
}
else if (i == count - ){
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(weakSelf.view).offset(-margin);
make.left.equalTo(tempView.mas_right).offset(margin);
make.centerY.equalTo(tempView);
make.height.equalTo(tempView);
make.width.equalTo(tempView);
}];
}
else{
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(tempView.mas_right).offset(margin);
make.centerY.equalTo(tempView);
make.height.equalTo(tempView);
make.width.equalTo(tempView);
}];
}
tempView = view;
[view layoutIfNeeded];
}
最新文章
- copy()之绝版应用
- const 与 readonly知多少
- Linux Shell脚本编程--Head/Tail命令详解
- ubuntu安装opencv
- PHP取整函数:ceil,floor,round,intval的区别详细解析
- 解决错误 Cannot await in the body of a catch clause
- iOS 7 UI Transition – Porting View Controller Layouts from iOS 6
- BZOJ1103[POI2007]大都市meg 题解
- PSAM卡与CPU(用户卡)的操作过程
- Spring mvc中@RequestMapping 6个基本用法整理
- Django入门笔记
- PKU《程序设计》专项课程_递归汉诺塔问题
- WorkStation 虚拟机迁移到 ESXi的后续处理.
- strstr(),strchr()
- Oracle性能诊断艺术-读书笔记(执行计划中显示 Starts, E-Rows, REM A-Rows and A-Time)等)
- python学习之RabbitMQ-----消息队列
- oracle 导入导出 dmp 的三种方式
- PLSA-概率潜语义分析(二)
- PLSQL启动很慢的问题
- 您必须先调用“WebSecurity.InitializeDatabaseConnection”方法,然后再调用";WebSecurity";类的任何其他方法。
热门文章
- PHP中$a &;&; $b = $c 语法的用法
- 关于一个flask的服务接口实战(flask-migrate,flask-script,SQLAlchemy)
- hadoop的自定义分组实现 (Partition机制)
- 嵌入式LInux之C语言提升篇---Skr Skr Up Up
- Fibonacci递归以及数组实现
- 实验4 [BX]和loop指令
- CSS布局遇到的问题小结
- LeetCode: 61. Rotate List(Medium)
- springboot shiro没有注解解决方案
- android 学习六 构建用户界面和使用控件