masonry框架的使用
来源:互联网 发布:数控编程的内容和步骤 编辑:程序博客网 时间:2024/05/17 22:56
1)框架写法的四步优化
#import "ViewController.h"
#import "Masonry.h"
@interfaceViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *blueView = [[UIViewalloc]init];
blueView.backgroundColor = [UIColorblueColor];
[self.viewaddSubview:blueView];
UIView *redView = [[UIViewalloc]init];
redView.backgroundColor = [UIColorredColor];
[self.viewaddSubview:redView];
[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.mas_equalTo(self.view.mas_top).multipliedBy(1).mas_offset(20);
// make.left.mas_equalTo(self.view.mas_left).multipliedBy(1).mas_offset(20);
//
// make.right.mas_equalTo(self.view.mas_right).multipliedBy(1).mas_offset(-20);
// make.bottom.mas_equalTo(self.view.mas_bottom).multipliedBy(1).mas_offset(-20);
// the first optmizi
// make.top.mas_equalTo(self.view.mas_top).mas_offset(20);
// make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
// make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
// make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-20);
//the second optmizi
make.top.mas_equalTo(self.view).mas_offset(20);
make.left.mas_equalTo(self.view).mas_offset(20);
make.right.mas_equalTo(self.view).mas_offset(-20);
make.bottom.mas_equalTo(self.view).mas_offset(-20);
//the third optmizi
// make.top.left.mas_equalTo(self.view).mas_equalTo(20);
// make.right.bottom.mas_equalTo(self.view).mas_offset(-20);
//the final optmizi
// make.edges.mas_offset(UIEdgeInsetsMake(20, 20, 20, 20));
}];
2)约束的更新和移除
#import "ViewController.h"
#import "Masonry.h"
@interfaceViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *blueView = [[UIViewalloc]init];
blueView.backgroundColor = [UIColorblueColor];
[self.viewaddSubview:blueView];
//make
[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(20,20, 20,20));
}];
//replace
[blueView mas_updateConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(50,50, 50,50));
}];
//remove
[blueView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(100,100, 100,100));
}];
}
@end
#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *blueView = [[UIViewalloc]init];
blueView.backgroundColor = [UIColorblueColor];
[self.viewaddSubview:blueView];
UIView *redView = [[UIViewalloc]init];
redView.backgroundColor = [UIColorredColor];
[self.viewaddSubview:redView];
[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.mas_equalTo(self.view).mas_offset(20);
make.right.mas_equalTo(self.view).mas_offset(-20);
make.height.mas_offset(100);
}];
[redView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(blueView.mas_bottom).mas_offset(50);
make.trailing.mas_equalTo(blueView);
make.height.mas_equalTo(blueView);
make.width.mas_equalTo(blueView).multipliedBy(0.5);
}];
}
@end
- Masonry框架的使用
- masonry框架的使用
- Masonry 框架的使用
- Masonry布局框架的使用
- Masonry布局框架的使用
- Masonry布局框架的使用
- Masonry布局框架的使用
- Masonry框架的基本使用
- Masonry布局框架的使用
- Masonry布局框架的使用
- Masonry布局框架的使用
- 关于AutoLayout的框架Masonry的使用
- Masonry的使用 ---关于AutoLayout的框架
- 第三方框架Masonry的基本使用
- Masonry框架的简单使用和介绍
- Masonry框架的整合和使用
- AutoLayout框架Masonry使用心得
- AutoLayout框架Masonry使用心得
- PHP文件的上传与下载
- Eclipse常用快捷键
- 初学几种设计模式的理解与体会
- MCV后端框架的实例(一)
- 深入浅出设计模式python版——观察者模式(observer)
- masonry框架的使用
- 红黑树
- jQuery的deferred对象详解
- OpenGL备忘7---Camera
- google谷歌官方的上拉刷新(可变的颜色)
- Hadoop:Found a swap file by the name "/etc/.hosts.swp"
- Dubbo架构设计详解
- JAVA Apache-CommonsCollections 序列化RCE漏洞分析
- leetcode66-Plus One(加1问题)