我试图将我的视图设置为" y值"(y-value(作为超级图高度的百分比(乘数(。我需要使用参考而不是价值约束来说明设备旋转。
等同于我在非自动layout中尝试的内容如下:
[self.labelView setFrame:CGRectMake(0, self.frame.size.height * 0.8, self.frame.size.width, 20)];
我要实现的是将视图的顶部限制设置为80%的监督高度的限制:
[self.labelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.mas_height).multipliedBy(0.8);
make.left.and.right.equalTo(self.contentView);
make.height.equalTo(20);
}];
但是,这种方法不起作用。砖石库是否可以?
而不是contentView.mas_height
使用contentView.mas_bottom
,尝试设置labelView.top
或labelView.bottom
约束,i think think 都应产生相同的结果:
[labelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView.mas_bottom).multipliedBy(0.8);
make.left.and.right.equalTo(self.contentView);
make.height.equalTo(@20);
}];
迅速等效
labelView.mas_makeConstraints { (make:MASConstraintMaker!) in
make.bottom.equalTo()(self.contentView.mas_bottom)!.multipliedBy()(0.8)
make.left.and().right().mas_equalTo()(self.contentView)
make.height.mas_equalTo()(20.0)
}