自动布局之masonry
来源:互联网 发布:元数据和数据元区别 编辑:程序博客网 时间:2024/05/21 16:59
@property (nonatomic, strong, readonly) MASConstraint left;
@property (nonatomic, strong, readonly) MASConstraint top;
@property (nonatomic, strong, readonly) MASConstraint right;
@property (nonatomic, strong, readonly) MASConstraint bottom;
@property (nonatomic, strong, readonly) MASConstraint leading;
@property (nonatomic, strong, readonly) MASConstraint trailing;
@property (nonatomic, strong, readonly) MASConstraint width;
@property (nonatomic, strong, readonly) MASConstraint height;
@property (nonatomic, strong, readonly) MASConstraint centerX;
@property (nonatomic, strong, readonly) MASConstraint centerY;
@property (nonatomic, strong, readonly) MASConstraint *baseline;
make.size.mas_equalTo(self.view).offset(-20);
make.centerX.equalTo(self.view.mas_centerX);
make.centerY.equalTo(self.view.mas_centerY);
make.center.mas_equalTo(self.view);
make.size.equalTo(secondview);
两个view就相同大小等同于
make.width.equalTo(green.mas_width);
make.height.equalTo(green.mas_height);
键盘弹出在消息方法里更新约束:
-(void)keyBoardWillShow:(NSNotification*)noti { // 获取键盘基本信息(动画时长与键盘高度) NSDictionary *userInfo = [noti userInfo]; CGRect rect = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue]; CGFloat keyboardHeight = CGRectGetHeight(rect); CGFloat keyboardDuration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 修改下边距约束 [_textField mas_updateConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-keyboardHeight); }]; // 更新约束 [UIView animateWithDuration:keyboardDuration animations:^{ [self.view layoutIfNeeded]; }];}
键盘收起时在textField代理方法中再次更新约束
-(void)keyboardWillDisappear:(NSNotification *)noti { // 获取键盘基本信息(动画时长与键盘高度) NSDictionary *userInfo = [noti userInfo]; CGRect rect = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];// CGFloat keyboardHeight = CGRectGetHeight(rect); CGFloat keyboardDuration =[userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; [_textField mas_updateConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-40); }]; [UIView animateWithDuration:keyboardDuration animations:^{ [self.view layoutIfNeeded]; }];}
greenView.backgroundColor= [UIColorgreenColor];
greenView.layer.borderWidth= 2;
greenView.layer.borderColor= [[UIColorblackColor]CGColor];
[self.viewaddSubview:greenView];
UIView *redView = [UIViewnew];
redView.backgroundColor= [UIColorredColor];
redView.layer.borderWidth=2;
redView.layer.borderColor= [[UIColorblackColor]CGColor];
[self.viewaddSubview:redView];
UIView *blueView = [UIViewnew];
blueView.backgroundColor= [UIColorblueColor];
blueView.layer.borderWidth= 2;
blueView.layer.borderColor= [[UIColorblackColor]CGColor];
[self.viewaddSubview:blueView];
[greenView mas_makeConstraints:^(MASConstraintMaker*make) {
make.top.mas_equalTo(padding);
make.left.mas_equalTo(padding);
make.right.mas_equalTo(redView.mas_left).offset(-padding);
make.bottom.mas_equalTo(blueView.mas_top).offset(-padding);
make.width.mas_equalTo(redView);//**************
}];
[redView mas_makeConstraints:^(MASConstraintMaker*make) {
make.top.height.bottom.mas_equalTo(greenView);
make.right.mas_equalTo(-padding);
make.left.mas_equalTo(greenView.mas_right).offset(padding);
}];
[blueView mas_makeConstraints:^(MASConstraintMaker*make) {
make.height.mas_equalTo(greenView);
make.bottom.mas_equalTo(-padding);
make.left.mas_equalTo(padding);
make.right.mas_equalTo(-padding);
- 自动布局之masonry
- 自动布局之Masonry
- iOS 自动布局框架学习之Masonry
- iOS自动布局框架之Masonry
- Masonry自动布局
- IOS Masonry自动布局
- Masonry 自动布局 cocopods
- 自动布局Masonry
- iOS 自动布局 Masonry
- masonry 轻量级自动布局
- Masonry自动布局
- Masonry - 自动布局
- Masonry自动布局使用
- OC----Masonry 自动布局
- Masonry与iOS自动布局
- Masonry与iOS自动布局
- iOS自动布局框架Masonry
- 自动布局-Masonry基础用法
- 批处理命令findstr正则表达式的基本用法
- 图像特征提取:图像的矩特征
- 字符串分隔(使用substr实现)
- 【剑指offer-Java版】05从尾到头打印链表
- 装饰者模式
- 自动布局之masonry
- javascript冒泡事件的意义及如何阻止冒泡事件
- Elasticsearch的script使用
- 【Asp.Net】日期控件DatePicker使用
- HashMap中红黑树的查找函数find()实现
- C# 中的委托和事件
- 久违的亲切
- java 反射获取成员
- 友盟统计