1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| //创建一个UITextField UITextField *textFild = [[UITextField alloc]init]; textFild.backgroundColor = [UIColor orangeColor]; [self addSubview:textFild]; [textFild mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(64 + 5); make.width.mas_equalTo(100); make.height.mas_equalTo(50); }]; //创建一个UIButton UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.backgroundColor = [UIColor redColor]; [self addSubview:button]; [button mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(textFild.mas_bottom).offset(5); make.left.equalTo(textFild); make.width.height.mas_equalTo(50); }]; //创建一个UIView UIView *view = [[UIView alloc]init]; view.backgroundColor = [UIColor brownColor]; [self addSubview:view]; [view mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(button.mas_bottom).offset(5); make.left.equalTo(button); make.width.height.mas_equalTo(50); }]; //创建一个UIScrollView UIScrollView *sc = [[UIScrollView alloc]init]; [self addSubview:sc]; [sc mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(textFild.mas_top); make.width.equalTo(@50); make.height.equalTo(@200); make.right.equalTo(@(-50)); }]; sc.contentSize = CGSizeMake(50, 800); sc.backgroundColor = [UIColor redColor]; sc.delegate = self;
|