Masonry icon indicating copy to clipboard operation
Masonry copied to clipboard

怎么约束最大高度

Open OCer opened this issue 8 years ago • 5 comments

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 但实际上,我发现我的设置好像并没有用,我也尝试过不同的优先级设置,并不行 希望有大神帮解下惑,先谢谢各位大佬了

OCer avatar Nov 27 '17 07:11 OCer

[make height].equalTo([self mas_width]).multipliedBy(1.777f); 这个权限可以变低点了

lichory avatar Nov 30 '17 02:11 lichory

可以使用不等关系lessThanOrEqualTo

c137Choi avatar Dec 06 '17 03:12 c137Choi

并不行 如果equalTo权限比lessThanOrEqualTo权限低 那么总是lessThanOrEqualTo生效,然后[make height].equalTo([self mas_width]).multipliedBy(1.777f);就没办法约束比例关系,因为这句不生效 如果equalTo权限比lessThanOrEqualTo权限高 那么lessThanOrEqualTo无效,这就意味着高度会超出范围 @lichory @OrisForest

OCer avatar Dec 21 '17 09:12 OCer

[make height].equalTo([self mas_width]).multipliedBy(1.777f).priorityHigh(); [make height].lessThanOrEqualTo(self);

dongpoRen avatar Jul 20 '18 08:07 dongpoRen

label.translatesAutoresizingMaskIntoConstraints = false label.widthAnchor.constraint(lessThanOrEqualToConstant: 120).isActive = true

You can use the maximum value set by the system widthAnchor。

ChoshimWy avatar Jan 18 '24 02:01 ChoshimWy