thedansaps
thedansaps

Reputation: 611

How to center a UIView using storyboard in Swift

I have a view inside another view which I create using storyboard, now I want to position my inner view center vertically. How can I achieve that?

Upvotes: 1

Views: 6067

Answers (2)

Mukesh
Mukesh

Reputation: 3690

First select the View and place in center of the nib,Then Tick the Horizontal Center in Container and Vertical Center in Container

enter image description here

Then Give Height and Width to the View,Your View is now centered.

enter image description here

Upvotes: 10

Long Pham
Long Pham

Reputation: 7582

Use NSLayoutConstraint (Center Horizontally, Center Vertically) with parent view. And you need set constraint (width, height) for this view. enter image description here

Upvotes: 0

Related Questions