美文网首页
iOS Masonry 在ScrollerView 自动设置Co

iOS Masonry 在ScrollerView 自动设置Co

作者: ZCY_YAM | 来源:发表于2017-01-09 11:45 被阅读17次
- (void)viewDidLoad {

[superviewDidLoad];

UIScrollView* sss = [UIScrollViewnew];

[self.viewaddSubview:sss];

sss.backgroundColor= [UIColorpurpleColor];

[sssmas_makeConstraints:^(MASConstraintMaker*make) {

make.edges.insets(UIEdgeInsetsMake(10,10,10,10));

}];

UIView* contentView = [UIViewnew];

[sssaddSubview:contentView];

contentView.backgroundColor= [UIColoryellowColor];

[contentViewmas_makeConstraints:^(MASConstraintMaker*make) {

make.edges.equalTo(sss);

make.width.equalTo(sss);

}];

UIView* redView = [UIViewnew];

redView.backgroundColor= [UIColorredColor];

[contentViewaddSubview:redView];

[redViewmas_makeConstraints:^(MASConstraintMaker*make) {

make.centerX.mas_equalTo(contentView);

make.width.height.mas_equalTo(300);

make.top.offset(100);

}];

UIView* blueView = [UIViewnew];

blueView.backgroundColor= [UIColorblueColor];

[contentViewaddSubview:blueView];

[blueViewmas_makeConstraints:^(MASConstraintMaker*make) {

make.centerX.mas_equalTo(contentView);

make.width.height.mas_equalTo(300);

make.top.offset(1220);

make.bottom.mas_equalTo(contentView).offset(-20);

}];

}

相关文章

网友评论

      本文标题:iOS Masonry 在ScrollerView 自动设置Co

      本文链接:https://www.haomeiwen.com/subject/lbzcbttx.html