Make UIView fill containing view using auto layout in Interface Builder instead of code

≡放荡痞女 提交于 2019-12-18 03:57:06

问题


How do I use auto-layout to make a child view fill its parent, or at least anchor all its edges to the parent view's edges?

I am using all four vertical and horizontal constraints in "Spacing to nearest neighbour", but when I run the app on a 3.5" device, the height of the view has not been automatically adjusted from 568 to 480 as expected.


回答1:


Pin the top space to superview, bottom space to superview, leading space to superview and trailing space to superview.

Then set edit the constraints like so:

Superview.Top >= View.Top and Superview.Bottom >= View.Bottom




回答2:


I would just set all "Spacing to nearest neighbor" to 0, and align horizontal and vertical center. That should do the trick.



来源:https://stackoverflow.com/questions/23847259/make-uiview-fill-containing-view-using-auto-layout-in-interface-builder-instead

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