24

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.

enter image description here

2
  • If it was working as expected in 7.3, could it be a bug with the Beta? Commented Jun 15, 2016 at 14:55
  • I also got this error in Xcode 8 beta. Commented Jun 18, 2016 at 10:14

6 Answers 6

52

In Xcode 8 the button content/title/image insets have moved to the Size Inspector tab:

Which seems quite logical by the way! 😀

Sign up to request clarification or add additional context in comments.

Comments

21

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

values

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

enter image description here

If you change the horizontal/vertical alignment controls I was able to the button image to my desired look I wanted

enter image description here

1 Comment

Perfect sollution. Worked for me
9

tl;dr: Set the "Style" to "Default"

(if you're on Xcode 13, iOS 15 or later)

enter image description here

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").

4 Comments

That fixed my issues on Xcode 14 for that same issue!!! Thanks
Been struggling with this for over half an hour and didn't seem to check the style. You're amazing!
That fixed it fore me except that the filled background with rounded edges are gone :(
while true YOU DON'T HAVE TO DO THIS. SIMPLY TOGGLE THE ALIGNMENT CONTROLS, see other answer.
0

Its weird,but it actually works until you add collectionview or tableview in your Viewcontroller. Try setting the inset without having the scrollview or tableview in your view controller

Comments

0

There is a weird behavior when having a UITableView or UIScrollView on the scene (as mentioned by @RAHUL JOSHI). Sample

Solution: Just ignore the previsualization bug as on runtime this will work normally.

Comments

-1

Content inset for button is working perfect in xcode 8 beta. See below screenshot that i have taken from xcode8 beta.

enter image description here

2 Comments

There is no way this is xcode 8 - the inset controls now have their own tab
Thank you @Dnaso for reply.But if you can check question asked and answer(have clearly mentation about xcode beta8.)have written about xcode beta 8.In xcode beta 8, there is option to give inset as shown in above screenshot.It's not wrong.Answer was given before release of xcode 8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.