简体   繁体   中英

Constraint to add more space between two UIViews

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM