I have a calculator app and I'm trying to add an inset to the buttons. I don't want to increase the space between the UIStackView items because that would make my button area bigger, which is not what I want. Instead - I want to make my buttons smaller. I have tried using button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
but that does nothing?
The buttons ONLY have aspect 1:1 constraint applied to them, and both the horizontal and vertical UIStackViews' Distribution is set to Fill Equally - Their width and heigh is never set and is determined by other elements on the screen, which is why I find it difficult to make them smaller programmatically in Swift.
UIStackView
s will fill an subview regardless to the frame, inset you set it. What you can do is embed each UIButton
in a UIView
, and add some constraints to give some padding.