区块链技术博客
www.b2bchain.cn

iOS 布局求职学习资料

本文介绍了iOS 布局求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

这篇博客总结下我接触过的iOS布局方式

Masonry/SnapKit

Masonry-Github🔗

Masonry最大的好处是用链式操作简化了NSLayoutConstraints的复杂语法,举个例子,分别用原生语法和Masonry来写一个距屏幕内边距10pt的一个正方体:

    // Masonry     self.masView = [UIView new];     self.masView.backgroundColor = UIColor.redColor;     [self.view addSubview:self.masView];      UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10);     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.edges.equalTo(self.view).with.insets(insets);     }];      // or     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.top.equalTo(self.view).offset(10);         make.left.equalTo(self.view).offset(10);         make.bottom.equalTo(self.view).offset(-10);         make.right.equalTo(self.view).offset(-10);     }];
//NSLayoutConstraints self.masView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addConstraints:         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:-10] ]];

本质上Autolayout遵循的这个算法:
iOS 布局
正好对应了NSLayoutConstraints的写法

这篇博客总结下我接触过的iOS布局方式

Masonry/SnapKit

Masonry-Github🔗

Masonry最大的好处是用链式操作简化了NSLayoutConstraints的复杂语法,举个例子,分别用原生语法和Masonry来写一个距屏幕内边距10pt的一个正方体:

    // Masonry     self.masView = [UIView new];     self.masView.backgroundColor = UIColor.redColor;     [self.view addSubview:self.masView];      UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10);     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.edges.equalTo(self.view).with.insets(insets);     }];      // or     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.top.equalTo(self.view).offset(10);         make.left.equalTo(self.view).offset(10);         make.bottom.equalTo(self.view).offset(-10);         make.right.equalTo(self.view).offset(-10);     }];
//NSLayoutConstraints self.masView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addConstraints:         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:-10] ]];

本质上Autolayout遵循的这个算法:
iOS 布局
正好对应了NSLayoutConstraints的写法

这篇博客总结下我接触过的iOS布局方式

Masonry/SnapKit

Masonry-Github🔗

Masonry最大的好处是用链式操作简化了NSLayoutConstraints的复杂语法,举个例子,分别用原生语法和Masonry来写一个距屏幕内边距10pt的一个正方体:

    // Masonry     self.masView = [UIView new];     self.masView.backgroundColor = UIColor.redColor;     [self.view addSubview:self.masView];      UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10);     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.edges.equalTo(self.view).with.insets(insets);     }];      // or     [self.masView mas_makeConstraints:^(MASConstraintMaker *make) {         make.top.equalTo(self.view).offset(10);         make.left.equalTo(self.view).offset(10);         make.bottom.equalTo(self.view).offset(-10);         make.right.equalTo(self.view).offset(-10);     }];
//NSLayoutConstraints self.masView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addConstraints:         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-10],         [NSLayoutConstraint constraintWithItem:self.masView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:-10] ]];

本质上Autolayout遵循的这个算法:
iOS 布局
正好对应了NSLayoutConstraints的写法

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » iOS 布局求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们