mafioso
mafioso

Reputation: 1632

How to change constraints when device is in landscape mode?

Is there a way to change the constraints? I want to change the height, centerX and centerY of the button if the device is in landscape mode.

Upvotes: 1

Views: 1817

Answers (3)

Punit
Punit

Reputation: 1340

If you are using Auto-Layout then make outlets of constraints and change your constraint's constant value as per your need.

Example: If your height constraint is heightOfView then set heightOfView.constant = x , in your landscape mode

Upvotes: 0

gurmandeep
gurmandeep

Reputation: 1247

The size class will help you change the constraints in landscape and portrait mode both and even for the device screen ratio. For more details have a look at Ray wenderlich Auto layout tutorial

Upvotes: -1

Vishal Sonawane
Vishal Sonawane

Reputation: 2693

You can use different constraints by using Size classes. Size classes allows you to add different constraints for various modes i.e landscape and Portrait for various devices.

Upvotes: 5

Related Questions