2016-03-30 179 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

這麼多紅色:(謝謝雖然:) –