How can I give constraints some margin from the center of superView

徘徊边缘 提交于 2021-01-29 19:30:52

问题


I am using auto layout. I have one UIView that takes place at 20px margin from the center of the superview.

Right now I have given the Top Space to superview that i have make in the iPhone 6+ Xib. but when i run in the iPhone 4 simulator it goes to too much down.

Any idea


回答1:


If you want the view to be placed relative to the center of the superview, you should be using centerX and/or centerY constraints, not a constraint to the top of the superview. In IB, if you choose the "Vertical Center in Container" constraint to center the view vertically, you can edit that constraint to change its constant value which will offset the view from the center by whatever number you choose.



来源:https://stackoverflow.com/questions/26191267/how-can-i-give-constraints-some-margin-from-the-center-of-superview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!