首页 > 其他 > 详细

Maonry 动态多个按钮布局,横向及纵向

时间:2019-05-07 13:03:51      阅读:288      评论:0      收藏:0      [点我收藏+]
 1     self.itemArray = [NSMutableArray array];
 2     for (NSInteger i=0; i < 6; i++) {
 3         UIButton *button = [[UIButton alloc] init];
 4         button.backgroundColor = [UIColor greenColor];
 5         UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonTapPressed:)];
 6         [button addGestureRecognizer:tapGesture];
 7         [self.view addSubview:button];
 8         [self.itemArray addObject:button];
 9     }
10     
11     [self.itemArray mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:15 leadSpacing:10 tailSpacing:10];
12     [self.itemArray mas_makeConstraints:^(MASConstraintMaker *make) {
13         make.top.equalTo(self.view).offset(100);
14         make.height.equalTo(@50);
15     }];

 

Maonry 动态多个按钮布局,横向及纵向

原文:https://www.cnblogs.com/xujinzhong/p/10824750.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!