I am setting two UIButtons programmatically which look like this:
I am trying to set the image and text insets to be the same in buttons, but somehow left button's image is located differently than the right one. I have this extension to UIButton class:
func setTextAndImageForButton(spacing: CGFloat) {
let insetAmount = spacing / 2
imageEdgeInsets = UIEdgeInsets(top: 8, left: 4, bottom: 8, right: insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: 4, bottom: 0, right: -insetAmount)
contentEdgeInsets = UIEdgeInsets(top: insetAmount, left: 0, bottom: insetAmount, right: insetAmount*1.5)
}
As far as I understand when I set the insets for image, text and whole content, it should be located in the same place for both instances.
Are the insets override somehow after I set them in code?