I have a ViewController with a radial gradient background. Inside that I have a UITableView with cells and sections. Now I want to show the gradient behind the table view as you scroll. The issue is that when the section locks at the top you can see the cells behind the section. I would set the section background color but if I do that it does not match the radial gradient background. Is there anyway to have the cells clip under the sections while keeping the clearColor background?
Share
if I understand it, you want a completely clear tableview and tableview cell so you can see the background of your view controller.
You can achieve this by setting the tableview as having no background
and also the cell
if you also want the section to be transparent, you can use this method:
to make a custom view (for example create an image view with a transparent .png for the background)
I hope I understand your question correctly.
edit after clarification
to give the appearance that the cells stop before going underneath the section header:
make a class that is a subclass of uitableview with this ivar:
obviously this will create a gradient but if you wanted you could either tweak it or use
CALayerand instead of programmatically creating the mask, create a .png with the correct width/height of your section header.ANYWAY: if you use the
CAGradientLayer:then in your view controller:
The basic idea is a mask, you create a mask shape on the top of your tableview that is the same size as your section header. it will appear that the cells “disappear” behind it. It’s a bit tricky, but it will work.