< 返回首页

标哥的笔记,是记录在日常学习技术和日常开发中那些年遇到过的坑!本站为新站,原"标哥的技术博客"中的文章会慢慢移到本站,欢迎收藏本站!
在使用本站过程中,有任何建议请联系标哥! 另,承接App开发、网站开发和微信小程序开发!欢迎联系我们


iOS NSLayoutAttributeLeft与NSLayoutAttributeLeading的区别

 作者:标哥    发布日期:2017-01-13 11:10    阅读量:1511次
 

在使用Masonry时,有mas_leftmas_leading,同样有mas_rightmas_trailing,在中国都习惯左、右布局,使用left/rightheading/trailing是一样的。但是,在其它部分国家,开发者们的习惯不都是左、右或者前、后布局,还有右、左或者后、前布局的,因此是不一样的。

在中国,就放心的使用左、右或者前、后的方式吧。

Masonry属性

@property (nonatomic, strong, readonly) MASViewAttribute *mas_left;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_top;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_right;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_leading;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing;

我们看到这几个属性,但是我们并不需要都使用,因为在中国人的行为习惯中,大家都习惯从左到右的方式布局。我们完全可以不使用mas_leadingmas_trailing

对于苹果原生约束的枚举NSLayoutAttribute中的几个:

NSLayoutAttributeLeft = 1,
NSLayoutAttributeRight,
NSLayoutAttributeTop,
NSLayoutAttributeBottom,
NSLayoutAttributeLeading,
NSLayoutAttributeTrailing,

我们更常见的是使用leadingtrailing而不是left/right

推荐

笔者所见过使用Masonry的写法中,几乎没有见过使用mas_leading/mas_trailing的,几乎都是使用mas_left/mas_right,当然也包括笔者。

因此,笔者也推荐大家使用Masonry时,使用mas_left/mas_right,但是使用xib/storyboard上的约束时,使用heading/trailing最多。


承接:ThinkPHP项目开发、网站项目开发、微信项目开发、微信小程序项目开发、App开发,欢迎联系标哥QQ632840804