UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Day 19 - Project 2 - Constraints and Button Padding

Forums > 100 Days of Swift

Hello, I am running XCode 13 and have run into an annoying visual issue with Day 19 - Project 2. I have the flag buttons set up as 200x100, but as soon as I add constraints to them the dimensions change to 224x114 producing an ugly padded border around the image.

I have looked around the options of the interface builder and have played with settings but nothing seems to allow the removal of that padding with constraints.

Am I just missing it or am I stuck just positioning the buttons by hand?

Manual positioning displays the bordered flags correctly, but I would imagine they would have issues on differnt devices.

Thanks in advance for any tips.



Figured out the solution to this. It seems that you have to create each button from scratch rather than copy buttons. Feels super inefficient, especially for a visual editor such as Interface Builder, but good to have a solution.


I have the same issue, despite making it from scratch result is the same. After setting constraints as in video it changes to 224x114. Weird...


Seems like once you've changed Button from <Type: System -> to Type: Custom> and from <Style: Plain -> to Style: Default> in Attributes Inspector such nuisance will go away!


Thank you, ygeras. I followed your instructions and solved the issue. :)


@ygeras Though this was posted a year ago, only Your solution worked. I was so mad that I couldn't fix that. Tried everything except that I mean it wouldn't reach my mind to change those settings. Thank You!


I had 2 problems:

  1. the border padding
  • this was solved with NOT copying the buttons but manually dragging all 3 from the objects library
  1. the width was always larger than the image despite aspect ration of 2:1
  • this was solved but deleting the button text, it looks like the button size allows for text automatically

  • the buttons also had to set to Custom type with Default Style

I hope this can help someone else, it took me a too long to work this out.


Thanks folks! I had to delete the title again after I changed the style to default and it worked as intended.


TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.