使用自动布局隐藏/显示图像?

时间:2016-01-14 16:14:29

标签: swift nslayoutconstraint size-classes ios-autolayout

我想要在3.5屏幕this guy上移除一个小角色的图像。值选择器仅提供3.5,4和4.7。我只想要3.5!这是否必须以编程方式完成。I want only 3.5

1 个答案:

答案 0 :(得分:0)

覆盖viewcontroller中的updateConstraint方法

override func updateConstraints() {
    //do something here with the constraint
    self.yourconstraint.constant = ?

    //or you can inactive a constraint
    NSLayoutConstraint.activateConstraints([yourConstraint])

    //then you can put logic here : where your screen size 320
    if (Screen.size.width == 320) {
       //update your constraint
    }
    super.updateContraint()
}