前言
在使用Masonry
时,有mas_left
与mas_leading
,同样有mas_right
与mas_trailing
,在中国都习惯左、右布局,使用left/right
与heading/trailing
是一样的。但是,在其它部分国家,开发者们的习惯不都是左、右或者前、后布局,还有右、左或者后、前布局的,因此是不一样的。
在中国,就放心的使用左、右或者前、后的方式吧。
Masonry属性
1
2
3
4
5
6
7
8
|
@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_leading
和mas_trailing
对于苹果原生约束的枚举NSLayoutAttribute
中的几个:
1
2
3
4
5
6
7
8
|
NSLayoutAttributeLeft
=
1
,
NSLayoutAttributeRight
,
NSLayoutAttributeTop
,
NSLayoutAttributeBottom
,
NSLayoutAttributeLeading
,
NSLayoutAttributeTrailing
,
|
我们更常见的是使用leading
和trailing
而不是left/right
。
推荐
笔者所见过使用Masonry
的写法中,几乎没有见过使用mas_leading/mas_trailing
的,几乎都是使用mas_left/mas_right
,当然也包括笔者。
因此,笔者也推荐大家使用Masonry
时,使用mas_left/mas_right
,但是使用xib/storyboard
上的约束时,使用heading/trailing
最多。