- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
button.frame = CGRectMake(0, 0, 50, 50);
button.tag = 1001;
[button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
UIView *sv2 = [[UIView alloc] init];
sv2.backgroundColor = [UIColor redColor];
UIView *sv3 = [[UIView alloc] init];
sv3.backgroundColor = [UIColor greenColor];
UIView *sv4 = [[UIView alloc] init];
sv4.backgroundColor = [UIColor blueColor];
UIView *sv = self.view;
[sv addSubview:sv2];
[sv addSubview:sv3];
[sv addSubview:sv4];
int padding1 = 10;
[sv2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(sv.mas_centerY);
make.left.equalTo(sv.mas_left).with.offset(padding1);
make.right.equalTo(sv3.mas_left).with.offset(-padding1);
self.constraint = make.height.equalTo(@150);
make.width.equalTo(sv3);
}];
[sv3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(sv.mas_centerY);
make.left.equalTo(sv2.mas_right).with.offset(padding1);
make.right.equalTo(sv4.mas_left).with.offset(-padding1);
make.height.equalTo(@150);
make.width.equalTo(sv4);
}];
[sv4 mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(sv.mas_centerY);
make.left.equalTo(sv3.mas_right).with.offset(padding1);
make.right.equalTo(sv.mas_right).with.offset(-padding1);
make.height.equalTo(@150);
make.width.equalTo(sv2);
}];
}
- (void)clickButton:(UIButton *)sender {
if (sender.tag == 1001) {
sender.tag = 1002;
self.constraint.equalTo(@50);
}else if (sender.tag == 1002) {
sender.tag = 1001;
self.constraint.equalTo(@150);
}
}
Created
June 25, 2016 06:38
-
-
Save tailang/1859f4d596193acf2a62f3aebbcebbd6 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment