ios - masonry第三方库使用自动布局(参考:http://www.cocoachina.com/ios/20141219/10702.html)
#import "ViewController.h"
#import "Masonry.h"
#define kWeakSelf(weakSelf) __weak typeof(self)weakSelf = self
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self
@interface ViewController ()
{
UIView *topView;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
kWeakSelf(ws);
/**底部灰色view*/
topView = [[UIView alloc]init];
topView.backgroundColor = [UIColor lightGrayColor];
[ws.view addSubview:topView];
[topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(ws.view);
make.size.mas_equalTo(CGSizeMake(, )); }];
/**表面红色view*/
UIView *redView= [[UIView alloc]init];
redView.backgroundColor = [UIColor redColor];
[topView addSubview:redView];
[redView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(topView).with.insets(UIEdgeInsetsMake(, , , )); }]; /**
创建三个等宽等高等间距view
*/
/**左边view*/
UIView *leftView = [[UIView alloc]init];
leftView.backgroundColor = [UIColor blueColor];
[redView addSubview:leftView];
/**右边view*/
UIView *rightView = [[UIView alloc]init];
rightView.backgroundColor = [UIColor brownColor];
[redView addSubview:rightView]; /**最有边view*/
UIView *lastView = [[UIView alloc]init];
lastView.backgroundColor = [UIColor yellowColor];
[redView addSubview:lastView]; CGFloat padding = .f;
//左边view添加约束
[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(redView.mas_centerY);
make.left.equalTo(redView.mas_left).with.offset(padding);
make.right.equalTo(rightView.mas_left).with.offset(-padding);
make.height.mas_equalTo(@);
make.width.equalTo(rightView);
}];
//右边view添加约束
[rightView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(redView.mas_centerY);
make.left.equalTo(leftView.mas_right).with.offset(padding);
make.right.equalTo(lastView.mas_left).with.offset(-padding); make.height.mas_equalTo(@);
make.width.equalTo(lastView); }];
//最右边view添加约束
[lastView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(redView.mas_centerY);
make.left.equalTo(rightView.mas_right).with.offset(padding);
make.right.equalTo(redView.mas_right).with.offset(-padding);
make.width.equalTo(rightView);
make.height.mas_equalTo(@);
}];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; } @end

ios - masonry第三方库使用自动布局(参考:http://www.cocoachina.com/ios/20141219/10702.html)的更多相关文章
- Swift中的Masonry第三方库——SnapKit
在OC开发时我常用一个名叫Masonry的第三方Autolayout库,在转Swift后发现虽然Swift可以混编OC,但总感觉有些麻烦,在Github上发现了这个叫做SnapKit的第三方库,发现使 ...
- IOS常用第三方库《转》
UI 动画 网络相关 Model 其他 数据库 缓存处理 PDF 图像浏览及处理 摄像照相视频音频处理 响应式框架 消息相关 版本新API的Demo 代码安全与密码 测试及调试 AppleWatch ...
- iOS常用第三方库大全,史上最全第三方库收集
下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...
- Swift中的Masonry第三方库——SnapKit
在OC开发时我常用一个名叫Masonry的第三方Autolayout库,在转Swift后发现虽然Swift可以混编OC,但总感觉有些麻烦,在Github上发现了这个叫做SnapKit的第三方库 ...
- iOS之第三方库以及XCode插件介绍
前言 第三方库是现在的程序员离不开的东西 不光是APP开发 基本上所有的商业项目 都会或多或少的使用到第三方库 Github上Star>100的开源库数量如下 可以看到JS以绝对的优势排名第一 ...
- ios 引入第三方库 运行时找不到函数实现
今天引入webtrends 这个库,结果一直运行时找不到函数,纳闷了一下午! 后来发现,是other flag没有设置对,对于那些包含category用来扩展ios原始类型的库,链接的时候需要特别的链 ...
- iOS开发第三方库一 IQKeyboardManager
每一个iOS应用的开发者在工作中都会遇到需要用户键盘输入数据的需求,而输入框(UITextField/UITextView)的父界面可能是普通的UIView,也可能是UIScrollView,UITa ...
- iOS:第三方库使用非ARC编译
iOS: 解决某些第三方库因为ARC不能使用的问题 1.在target下面的build phases下有一个compile source,下面有很多待编译文件.可以看到一个compile flag,可 ...
- ios常用第三方库git下载地址
本文转载至 http://blog.csdn.net/cerastes/article/details/38348599 iOS第三方库下载常用git 1.FMDB https://github.co ...
随机推荐
- MATLAB图形界面设计(下)
文章参考Blue Mountain https://www.cnblogs.com/BlueMountain-HaggenDazs/p/4307777.html 一.菜单设计 1.建立菜单项 (1)建 ...
- eas之action的创建
protected KDWorkButton btnFileManage; protected ActionFileManage actionFileManage = null; pub ...
- 使用yum update更新文件系统时不更新内核的方法
CentOS使用yum update更新时不升级内核 cp /etc/yum.conf /etc/yum.confbak 方法一.修改yum的配置文件 vi /etc/yum.conf 在[m ...
- PHP过滤html注释
过滤html注释: 所谓过滤,不过是字符串的匹配与替换,这里我们用到的正则匹配替换函数preg_replace(reg,replace,string);,PHPer都清楚,这个函数的关键在于reg的精 ...
- 5、SpringBoot+MyBaits+Maven+Idea+pagehelper分页插件
1.为了我们平时方便开发,我们可以在同一个idea窗口创建多个项目模块,创建方式如下 2.项目中pom.xm文件的内容如下 <?xml version="1.0" encod ...
- Laravel 5
遍历数组@foreach($brand as $v) <a href='/brandss/seeshops?id={{$v->id}}'><img src="/pub ...
- MDK(KEIL5)如何生成.bin文件 【转】
最近要做个bin文件,网上找了好多都说的不够清楚,后来找到一篇实测可用,说明清楚的,转过来以便学习用. 参考传送门:https://blog.csdn.net/nx505j/article/detai ...
- Netty学习总结(3)——Netty百万级推送服务
1. 背景 1.1. 话题来源 最近很多从事移动互联网和物联网开发的同学给我发邮件或者微博私信我,咨询推送服务相关的问题.问题五花八门,在帮助大家答疑解惑的过程中,我也对问题进行了总结,大概可以归纳为 ...
- 转载 - Tarjan算法(求SCC)
出处:http://blog.csdn.net/xinghongduo/article/details/6195337 说到以Tarjan命名的算法,我们经常提到的有3个,其中就包括本文所介绍的求强连 ...
- H - Can you answer these queries? ( POJ - 3264 )
H - Can you answer these queries? HDU - 4027 思路: 一眼思路:线段树区间修改,区间查询. 发现bug:区间的sqrt无法实现,所以还是相当于对区间的每 ...