[英]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?
我该如何实现?
First select the View and place in center of the nib,Then Tick the Horizontal Center in Container and Vertical Center in Container 首先选择“视图”并放置在笔尖的中心,然后在“容器”中勾选“水平中心”并在“容器”中勾选“垂直中心”
Then Give Height and Width to the View,Your View is now centered. 然后将“高度”和“宽度”赋予视图,您的视图现在居中。
Use NSLayoutConstraint (Center Horizontally, Center Vertically) with parent view. 将NSLayoutConstraint(水平居中,垂直居中)与父视图一起使用。 And you need set constraint (width, height) for this view.
并且您需要为此视图设置约束(宽度,高度)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.