Mugunth Chandran
Mugunth Chandran

Reputation: 271

How to set constraints for iPhone X device alone

I have a logo in the storyboard set to a top constraint of value 28 and it works for all devices. On iPhone X device it merges with the camera bar on the top. If i increase the top constraint it affects the other devices. How do i set a constraint only for iPhone X alone?

Upvotes: 2

Views: 2295

Answers (1)

dispatchswift
dispatchswift

Reputation: 1056

By default Xcode provides you with a Safe Area upon project creation.

enter image description here

Here, I've added a UIView with the following constraints. Take note of how the constraints are pinned to the Safe Area, and not the Superview. enter image description here

Running the app, you'll see that the view respects the status bar across all devices.

Hope this helps with the issue you're having...

Upvotes: 7

Related Questions