-2

I have a view divided in 5 pieces with 4 lines (which are views too with a height of 1). I am making my swift app responsive with different apple devices sizes but the problem is that the y position of the small views is not changing with the device size and it's making the interface ugly . The question is how make the y position of each small view take a value of 1/5 of the big view. Note that I am new to multipliers and advanced constraints. I hope i've made my question clear and thanks in advance. Edit: picture 1 picture2 Sorry I can't upload picture due to reputation but here are two links to the pictures

  • Can you provide some screenshot of simulator and/or storyboard so your problem would be more clear? – Yury Imashev Sep 16 '18 at 21:17
  • Please see post edit – Bettaieb Amine Sep 16 '18 at 21:25
  • Unclear how the question relates to the pictures. Which are the "small views" and the "big view"? – matt Sep 16 '18 at 21:29
  • So, the problem is that there is some blank space under the last view. What would you like to get? For example, all views might have the same height or space between them can make then fill the screen. – Yury Imashev Sep 16 '18 at 21:30
  • @YuryImashev that's what i am trying to get , I want those labels (Anniversaire, Adresse, Profession , status and Enfants) to have the same height and occupy the hole view , which in my picture is not the case for the ipad – Bettaieb Amine Sep 16 '18 at 21:34

3 Answers3

0

It sounds like you are a describing a stack view (UIStackView) with five arranged views in Fill Equally mode. It will cause each of the five subviews to occupy 1/5 of its own height.

enter image description here

enter image description here

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

I'm not sure how exactly you set up your "small" views, but I'd recommend you to use UIStackView to achieve the desired effect. Here you can read more about it.

  1. Using the Interface Builder add Vertical Stack View to your view controller.
  2. Place your "small" views in it.
  3. Using the Interface Builder, set Distribution parameter to Fill Equally.

After this, UIStackView will keep you small views height equal and the fill its height.

Yury Imashev
  • 2,068
  • 1
  • 18
  • 32
0

I set this up using a UIStackView containing 5 views and 4 views to serve as the lines.

Here is the setup for the stack view:

stack view setup in Xcode

Here is the setup of the view hierarchy and constraints:

view hierarchy and constraints in Xcode


Notes:

  1. The lines have constraints which set their height to 1 point.
  2. Views 2 through 5 have their heights set equal to View 1's height.
  3. The size of the stack view is constrained to the safe area.
vacawama
  • 150,663
  • 30
  • 266
  • 294