- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UILabel *nameL = [[UILabel alloc]init];
[self.view addSubview:nameL];
nameL.text = @"hh名字: ";
nameL.backgroundColor = [UIColor yellowColor];
nameL.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
[nameL mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(100);
make.left.mas_equalTo(15);
}];
//设置Label的水平抗压缩 这样就不会变形了
[nameL setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
UITextField *hhTF = [[UITextField alloc]init];
[self.view addSubview:hhTF];
hhTF.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
hhTF.placeholder = @"hhhhh";
[hhTF mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(nameL.mas_bottom);
make.left.mas_equalTo(nameL.mas_right).mas_offset(15);
make.right.mas_equalTo(-15);
make.height.mas_equalTo(30);
}];
hhTF.backgroundColor = [UIColor yellowColor];
}