【发布时间】:2019-10-01 22:46:23
【问题描述】:
我正在尝试将我的视图顶部约束(y 值)设置为超级视图高度的百分比(乘数)。我需要使用参考而不是值约束来解释设备旋转。
我在非自动布局中尝试的等价物如下:
[self.labelView setFrame:CGRectMake(0, self.frame.size.height * 0.8, self.frame.size.width, 20)];
我想要实现的是将视图的 TOP 约束设置为超级视图高度的 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);
}];
但是,这种方法行不通。 Masonry 库可以做到这一点吗?
【问题讨论】:
-
我对 Masonry 不熟悉,但我使用了约束。试试看:
make.top.equalTo(self.contentView.bottom).multipliedBy(0.8);
标签: ios objective-c swift autolayout masonry-ios-osx