iOS NSLayoutAttributeLeft与NSLayoutAttributeLeading的区别

iOS NSLayoutAttributeLeft与NSLayoutAttributeLeading的区别

在使用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最多。

关注我


微信公众号:iOSDevShares
有问必答QQ群:324400294

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值