NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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.

   

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!

1      

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

   

Thanks @mateuz!

I'm working on <a href='https://thexploretech.com/'></a> and I was facing same problem. Thanks for sharing your experience regarding this issue.

Regards.

   

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 RevenueCat

SPONSORED Building and maintaining in-app subscription infrastructure is hard. Luckily there's a better way. With RevenueCat, you can implement subscriptions for your app in hours, not months, so you can get back to building your app.

Try it for free

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.