怎么约束最大高度
New Issue Checklist
🚫 If this template is not filled out your issue will be closed with no comment. 🚫
- [√ ] I have looked at the Documentation
- [ √] I have filled out this issue template.
Issue Info
| Info | Value |
|---|---|
| Platform | ios |
| Platform Version | 9.0 |
| Masonry Version | 1.1 |
| Integration Method | manually |
Issue Description
[make height].equalTo([self mas_width]).multipliedBy(1.777f); [make height].lessThanOrEqualTo(self).priorityHigh();
我想要的结果,height的值是self width的1.777倍,并且最大值只能和self height一样 也就是说,如果self的宽度*1.777大于self height的时候,高度就是height 但实际上,我发现我的设置好像并没有用,我也尝试过不同的优先级设置,并不行 希望有大神帮解下惑,先谢谢各位大佬了
[make height].equalTo([self mas_width]).multipliedBy(1.777f); 这个权限可以变低点了
可以使用不等关系lessThanOrEqualTo
并不行 如果equalTo权限比lessThanOrEqualTo权限低 那么总是lessThanOrEqualTo生效,然后[make height].equalTo([self mas_width]).multipliedBy(1.777f);就没办法约束比例关系,因为这句不生效 如果equalTo权限比lessThanOrEqualTo权限高 那么lessThanOrEqualTo无效,这就意味着高度会超出范围 @lichory @OrisForest
[make height].equalTo([self mas_width]).multipliedBy(1.777f).priorityHigh(); [make height].lessThanOrEqualTo(self);
label.translatesAutoresizingMaskIntoConstraints = false label.widthAnchor.constraint(lessThanOrEqualToConstant: 120).isActive = true
You can use the maximum value set by the system widthAnchor。