iOS different constraints for different devices

前端 未结 4 1433
星月不相逢
星月不相逢 2020-12-16 16:34

I have a ViewController designed for iPhone SE

As you can see I also have a constraint Align Top to: Safe Area Equals 75

The question i

4条回答
  •  猫巷女王i
    2020-12-16 17:16

    This is not applicanle in IB , you can try in code by hooking the top constraint of the view as IBOutlet and in viewDidLayoutSubviews

    override func viewDidLayoutSubviews()
    {
    
       if(deviceWidthSE)
       {      
          self.viewTopCon.constant = 75
       }
       else
       if(deviceWidth8)
       {
          self.viewTopCon.constant = 85
       }
       else
       if(deviceWidth8Plus)
       {
          self.viewTopCon.constant = 105
       }
    
    }
    

提交回复
热议问题