WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

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


Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

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

Reply to this topic…

You need to create an account or log in to reply.

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.