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

Day 23 – Milestone: Projects 1-3 CHALLENGE

Forums > 100 Days of Swift

@aDayu  

Hello,

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.

3      

Hello,

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: https://www.youtube.com/watch?v=Xm9jaqiUiTA.

Cheers!

4      

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

3      

@Haibo  

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

See this thread https://stackoverflow.com/questions/6216839/how-to-add-spacing-between-uitableviewcell/36060215#comment113478925_36060215

@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

3      

Thanks @mateuz!

I'm working on https://thexploretech.com/internet-download-manager-serial-number/ and I was facing same problem. Thanks for sharing your experience regarding this issue.

Regards.

3      

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.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.