Constraint to add more space between two UIViews

主宰稳场 提交于 2019-12-11 05:04:56

问题


I'm developing an iPhone application with XCode 4.5.2 and latest SDK.

Now I'm using Autolayout to work with one storyboard and use it with iPhone 4S and iPhone 5.

This is how can you see it with Retina 3.5 form factor:

And this is how you can see it with Retina 4 form factor:

I need to add more space between Todos los establecimientos and Todos los products. And also, between Todos los products and Por distancia >.

Todos los establecimientos and Todos los products now have a Top Space to: Superview constraint.

How can I do to add more space between those elements when I use Retina 4 form factor?


回答1:


This can be done via a constraint with less than 1.0 Priority. To create a constraint between 2 views select both and click on the constraint button in the lower right corner of the interface builder to select the constraint you need in this case vertical spacing..

Raywenderlich has a good tutorial on this: Part 1 Part 2

Or read Apples documentation: Apple Guide - Understanding Constraints




回答2:


If you want the "Busqueda por filters" label and the "Por valoracion" labels to maintain their fixed distances to the top and bottom (respectively), then you could embed "Todos los establecimientos", "Todos los products", and "Por distancia" in a view. Those three items will have fixed spaces to the top, middle and bottom of that view. Give that view vertical spacing constraints to the "Busqueda por filters" label above, and "Por valoracion" label below, and remove any spacing constraints to the top or bottom of the main view. When the screen size gets bigger, this view will stretch giving more space between its views.



来源:https://stackoverflow.com/questions/14383058/constraint-to-add-more-space-between-two-uiviews

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