2016-03-30 182 views
0

是否有可能具有设定制约..例如:的iOS 9约束小于或等于X减&&大于或等于Y

Less than or equal to 100 but Greater than or equal to 50

这是为了使在较小的设备(我很难在iPhone 3.5英寸高达4.7英寸,因为他们都在相同的大小类看到良好的意见)我的意见会缩小,但只有一定的点,所以他们仍然可读?

+1

是的,使用两个约束。 – Fogmeister

回答

1

是的。你需要这样的东西:

let constraint1 = NSLayoutConstraint(item: i, attribute: .Height, relatedBy: .GreaterThanOrEqual, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 100) 
let constraint2 = NSLayoutConstraint(item: i, attribute: .Height, relatedBy: .LessThanOrEqual, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 200) 

然后将两个约束添加到适当的视图。

+0

有没有什么方法可以让它在不影响我的故事板上的约束错误的情况下工作? –

+0

不是我所知道的。 –

+0

这么多红色:(谢谢虽然:) –