正确的这一种:
[btnCancle mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(80);
make.height.mas_equalTo(40);
// make.left.equalTo(view).with.offset(10);
make.left.mas_equalTo(10);
// make.top.equalTo(view).with.offset(10);
make.top.mas_equalTo(10);
}];
不正确的这一种:
不需要make.size ,直接make.width.
不需要make.top.equalsTo(view)with.offset(10); ,直接make.top.mas_equalto(10);默认的话,就是相对于父控件的。
UIButton *btnOK = [[UIButton alloc]init];
[btnOK setTitle:@"完成" forState:UIControlStateNormal];
[btnOK addTarget:self action:@selector(recordOk) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:btnOK];
[btnOK mas_makeConstraints:^(MASConstraintMaker *make){
make.size.width.mas_equalTo(50);
make.size.height.mas_equalTo(40);
make.top.equalTo(view).with.offset(10);
make.right.equalTo(view).with.offset(-10);
}];