__block UIView *lastView=nil;
int intes =SP_Floatt(10);
int num=5;
for (int i=0; i<10; i++) {
UIButton *imageB=[UIButton buttonWithType:UIButtonTypeCustom];
[imageB setImage:[UIImage imageNamed:[NSString stringWithFormat:@"1.png"]] forState:UIControlStateNormal];
[self.view addSubview:imageB];
[imageB mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(SP_Floatt(80));
if (lastView) {
make.width.equalTo(lastView);
}else{
if (i % num!=0) {
make.width.mas_equalTo((weakSelf.view.frame.size.width-(num+1)*intes/11));
}
}
if (i%num==0) {
make.left.mas_equalTo(weakSelf.view).offset(intes);
}else{
make.left.mas_equalTo(lastView.mas_right).offset(intes);
}
if (i%num==(num-1)) {
make.right.mas_equalTo(weakSelf.view).offset(-intes);
}
if (i / num == 0) {
make.top.mas_equalTo(xuanze.mas_bottom).offset(intes);
} else {
make.top.mas_equalTo(xuanze.mas_bottom).offset(intes+80);
}
}];
lastView=imageB;
}
网友评论