3

I am having problems using stack view with different sized buttons.

This is what I am trying to achieve with StackView enter image description here

I'm having issues with stack view because buttons '=' and '0' are different size.

This is what I've managed, but you can see the the alignment is not correct and the sizing is off. enter image description here

By looking at the images, does anyone have any suggestions on how I can achieve the desired look?

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
breaktop
  • 1,899
  • 4
  • 37
  • 58
  • What about using `UICollectionView`, I think its much better. It will give you another benefit to support devices before iOS 9 – Hossam Ghareeb Jun 05 '16 at 12:18
  • @HossamGhareeb I've not tried ```UICollectionView```. Since i'm building a calculator to work on all iOS devices I thought the StackView would be suitable for my Universal StoryBoard. I'm having issues because of the '=' and '+' buttons. They are different size. – breaktop Jun 05 '16 at 12:30

2 Answers2

1

Here is my solution(for = button). enter image description here

The Distributions of stack views is(from top to bottom in Outline):

Fill Proportionally

Fill

Fill Equally

Fill Equally

Community
  • 1
  • 1
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
0

try to set Alignment attributes to Center and Distribution to Equal Spacing for your UIStackView element, and set the view mode to Center for each UIButton elements at Attributes Inspector.

miletliyusuf
  • 982
  • 1
  • 10
  • 12