Recently I have updated Xcode 7.3 to 8. While opening the project the project settings also have been updated for new Xcode.
Now the insets given for a button image for positioning the image inside button frame is not working as in previous Xcode(7.3) version.
The image insets are given through storyboard. Image was used here to have large clickable area for button than the button image display area. Is there any other options to get it through storyboard.
In Xcode 8 the button content/title/image insets have moved to the Size Inspector tab:
Which seems quite logical by the way! π
I had this same problem and solved it with image insets and the Horizontal/Vertical Alignment controls. My problem was that I had the wrong alignment controls selected. Once I changed it my insets worked properly for what I was trying to accomplish.
I created a button with an image and the I wanted to shrink the image down to not fill up the entire button So I set the image to the UIButton image property in storyboard and then set the image insets to my liking
But it did not center my image with the inset of 5 on each side. The image would look like this and that was not what I wanted
If you change the horizontal/vertical alignment controls I was able to the button image to my desired look I wanted
tl;dr: Set the "Style" to "Default"
(if you're on Xcode 13, iOS 15 or later)
Long answer:
I know the very title of this question references Xcode 8 - but this comes up in a Google search and I had issues in Xcode 13 (iOS 15) where the content/title/image insets are not reflected in the storyboard or at runtime. This was due to the new button system, and the solution was to set the button's "Style" to "Default" (it was "Plain").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With