标签:
呐,Masonry 是用来布局的!CocoaPods上下载!
呐,来吧!开始鸟语......下面是从View+MASAdditions.h中抽出来的方法。
1 /** 2 * Creates a MASConstraintMaker with the callee view. 3 * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 4 * 5 * @param block scope within which you can build up the constraints which you wish to apply to the view. 6 * 7 * @return Array of created MASConstraints 8 */ 9 - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 10 11 /** 12 * Creates a MASConstraintMaker with the callee view. 13 * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 14 * If an existing constraint exists then it will be updated instead. 15 * 16 * @param block scope within which you can build up the constraints which you wish to apply to the view. 17 * 18 * @return Array of created/updated MASConstraints 19 */ 20 - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 22 /** 23 * Creates a MASConstraintMaker with the callee view. 24 * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 25 * All constraints previously installed for the view will be removed. 26 * 27 * @param block scope within which you can build up the constraints which you wish to apply to the view. 28 * 29 * @return Array of created/updated MASConstraints 30 */ 31 - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block;
土鳖式翻译开始... 对比:
mas_makeConstraints created
mas_updateConstraints created/updated If an existing constraint exists then it will be updated instead.
(如果现有的约束存在,那么它将被更新。)
mas_remakeConstraints created/updated All constraints previously installed for the view will be removed.
(视图上之前安装的所有约束将被删除。人家的意思是会保留最新哒)
简单使用方法:
人家想来个全屏的么,除了导航栏。
1 [myView mas_makeConstraints:^(MASConstraintMaker *make) { 2 make.top.equalTo(self.view.mas_top).with.offset(64);//上 3 make.left.equalTo(self.view.mas_left); //左 4 make.right.equalTo(self.view.mas_right);//右 5 make.bottom.equalTo(self.view.mas_bottom);//下 6 }];
其他方法自行脑补~揍四Autolayout。
下面贴个详细的帖子,I like ~~~ http://adad184.com/2014/09/28/use-masonry-to-quick-solve-autolayout/
标签:
原文地址:http://www.cnblogs.com/hanyutong/p/4770998.html