代码如下,添加之后xib中的约束就会变出一个开关:
import UIKit
let LayoutSCALE = screenWidth/414
extension NSLayoutConstraint {
@IBInspectable
var adapterScreen: Bool {
set {
if newValue {
self.constant = self.constant * LayoutSCALE
}
} get {
return true
}
}
}
如图,默认关掉的,需要手动开启