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

Day 23 – Milestone: Projects 1-3 CHALLENGE

Forums > 100 Days of Swift



I have finished all the requirments for this chanllenge, however, I'm struggling with how to add spacing between uitableview cells.

All my cell rows are bunched up together with no breathing room between the associated images and texts.



I strongly believe that in order to set the cell insets for the image, you would have to create a custom cell class. So, what I recommend to do now is to separate the flag images by adding borders to them. In cellForRowAt method put these 2 lines in:

cell.imageView?.layer.borderWidth = 1
cell.imageView?.layer.borderColor = UIColor.lightGray.cgColor

Now it should look better.

Once you reach the days where you learn about custom classes, you can go back to this project and improve it, using the technique from this video:



@MateusZ that was really helpful, but i was wondering about how to set border as well in the detail view controller to sarround the flags. i tried to set the broder to the image view itself but it was always far away and not sarrounding the flag itself.


Simply say using insets, but it is kind of tricky for default cell, prefer to use custom cell to do it.

See this thread

@sugertag Try to set imageView's aspect ratio to 2:1 in storyboard.

Or set its constraint programmtically. imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: 1.0/2.0).isActive = true


Thanks @mateuz!

I'm working on and I was facing same problem. Thanks for sharing your experience regarding this issue.



This is an internet site approximately Swift now not Android that why it referred to as Hacking with Swift and not Hacking with Android as you can see here.


Hacking with Swift is sponsored by Guardsquare

SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.

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