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.

-Jaime

4      

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.

4      

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

4      

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!

6      

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

4      

@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!

3      

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.

3      

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

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.