pjmanning
pjmanning

Reputation: 1311

Change Constraint from iPhone 7 and iPhone 7 Plus

I'm working with size classes in xcode and can't figure out how to change a layout constraint between the iPhone 7 and iPhone 7 Plus. Their size class is both Compact-Width Regular-Height so I'm a bit stumped.

Basically I want the button pictured below to have a top constraint of 446 for iPhone 7 and 500 for iPhone 7 Plus. I'm trying to do this through Interface Builder because this View Controller is from a pod.

enter image description here

Upvotes: 1

Views: 401

Answers (1)

Mohamed Helmy
Mohamed Helmy

Reputation: 832

link the top constraint

@IBOutlet weak var topCons: NSLayoutConstraint!

and

fire this

let screenSize: CGRect = UIScreen.main.bounds

    if screenSize.height > 700 // iphone 7 plus
    {
        topCons.constant = 500
    }

    else
    {
        topCons.constant = 446
    }

Upvotes: 1

Related Questions