-
-
Save hanfengs/df1e53ebdbbd63acfe630ccb00ac25dd to your computer and use it in GitHub Desktop.
[多选项(4或者更多),自动布局]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImageView *lastIV = nil; | |
self.ivArrM = [NSMutableArray array]; | |
for (NSInteger i = 0; i < 4; i++) { | |
UIImageView *iv = [[UIImageView alloc] init]; | |
[self addSubview:iv]; | |
[iv mas_makeConstraints:^(MASConstraintMaker *make) { | |
if (isPad) { | |
make.width.mas_equalTo(163); | |
}else{ | |
make.width.equalTo(self).multipliedBy(0.5).offset(-IVMragin16 * 1.5); | |
} | |
make.height.equalTo(iv.mas_width).multipliedBy(0.6); | |
if (lastIV) { | |
if (i%2 == 0) { | |
make.left.equalTo(self).offset(IVMragin16); | |
make.top.equalTo(lastIV.mas_bottom).offset(IVMragin16); | |
}else{ | |
make.left.equalTo(lastIV.mas_right).offset(IVMragin16); | |
make.top.equalTo(lastIV); | |
} | |
}else{ | |
make.left.equalTo(self).offset(IVMragin16); | |
make.top.equalTo(index.mas_bottom).offset(20); | |
} | |
}]; | |
lastIV = iv; | |
[self.ivArrM addObject:iv]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment