我在使用masonry自动布局时出现NSInternalInconsistencyException错误
xcode提示:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attributes should be chained before defining the constraint relation'
代码如下:
[self.view addSubview:btn];
[self.view addSubview:btn1];
__weak __typeof(&*self)weakSelf = self;
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(100, 50));
make.left.mas_equalTo(weakSelf.view).offset(200);
make.top.mas_equalTo(weakSelf.view).offset(200);
}];
[btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(100, 100));
make.left.mas_equalTo(weakSelf.view).with.offset(50);
make.top.mas_equalTo(weakSelf.view).width.offset(200);
}];
我写上面的那段代码的目的是为了替换
btn.frame = CGRectMake(200, 200, 100, 50);
btn1.frame = CGRectMake(50, 200, 100, 100);
not width, but with