簡體   English   中英

iOS 9限制小於或等於X &&大於或等於Y

[英]iOS 9 Constraints Less than or Equal X && Greater than or Equal Y

是否有可能將約束設置為..例如:

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

這樣一來,在較小的設備上(由於尺寸相同,我無法在3.5英寸至4.7英寸的iPhone上使視圖看起來很好),我的視圖會縮小,但只能縮小到一定程度,因此還是可讀?

是。 您需要類似:

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)

然后將兩個約束添加到適當的視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM