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

Guess the Flag Project - unwanted space between the flag and the border

Forums > 100 Days of Swift

Hi

I've completed the Guess the Flag project.

One thing I wasn't able to figure out is why after adding a border to my images, it is not touching the flag but has a gap around.

This is my code:

override func viewDidLoad() {
        super.viewDidLoad()

        countries += ["estonia", "france", "germany", "ireland", "italy", "monaco", "nigeria", "poland", "russia", "spain", "uk", "us"]

        button1.layer.borderWidth = 1
        button2.layer.borderWidth = 1
        button3.layer.borderWidth = 1

        button1.layer.borderColor = UIColor.lightGray.cgColor
        button2.layer.borderColor = UIColor.lightGray.cgColor
        button3.layer.borderColor = UIColor.lightGray.cgColor

        askQuestion(action: nil)

    }

You can see a capture here:

https://imgur.com/a/yL9wNBN

Thank you

3      

4      

Thank you for this. Just one more thing to add... Once you make these changes be sure to delete the Default title. "Button" will show back up and mess with your layout.

https://imgur.com/BCkcjJ4

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!

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.