iOS 9限制小于或等于X&&大于或等于Y.

时间:2016-03-30 13:41:10

标签: ios objective-c autolayout

是否可以将约束设置为..例如:

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

这样,在较小的设备上(我很难在iPhone 3.5英寸到4.7英寸之间看到良好的视图,因为它们都在同一尺寸级别),我的视图会缩小,但仅限于到某一点,所以它们仍然可读?

1 个答案:

答案 0 :(得分: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)

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