0

I'm currently has a View like this, how can I setup the constraint to display the items equally like the Iphone 7 review in all size of screen?. I've tried so many constraint including stackView but no use. Thank you very much and have good day ahead.

enter image description here

2 Answers2

0

You can use five view in the black view:

image

Constraint for first view:

  • leading space to superview : 0
  • Bottom and top space to superview : 0
  • trailing space to second view : 0

Constraint for second, third and fourth view:

  • leading space to left view : 0
  • Bottom and top space to superview : 0
  • trailing space to right view : 0
  • equal with and equal height with first view

Constraint for last(5th) view:

  • leading space to left view (4th) : 0
  • Bottom and top space to superview : 0
  • trailing space to superview : 0
  • equal with and equal height with first view

Then insert your button or element in these view with their constraint (eg. horizontal center / vertical center)

Cristina
  • 98
  • 2
  • 13
0

Use a UIToolbar which features a UIBarButtonSystemItemFlexibleSpace item that you can place in between your 5 regular items.

In Obj-C code you'd do something like:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.navigationController setToolbarHidden:NO];

    UIBarButtonItem* spaceItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                                                                                target:self
                                                                                action:nil];

    ... create other items ...

    self.toolbarItems = @[ item1, spaceItem1, item2, spaceItem2, ... ];

    ...
}
meaning-matters
  • 21,929
  • 10
  • 82
  • 142