1. 程式人生 > >Maonry 動態多個按鈕布局,橫向及縱向

Maonry 動態多個按鈕布局,橫向及縱向

aci ons span sax bject array table ger targe

 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 動態多個按鈕布局,橫向及縱向