I'm trying to set the background color of a UITableViewCell
to transparent. But nothing seems to work. I have some images/buttons inside the tableViewCell
and I would like to make the white grouptableview
background disappear to get a 'floating' effect for the images and buttons (as if they were not inside the tableview
).
Any idea how this could be accomplished?
Just select Clear Color on View Background for the table and for the cell also. Save this answer.
Any SwiftUI view can be partially or wholly transparent using the opacity() modifier. This accepts a value between 0 (completely invisible) and 1 (fully opaque), just like the alpha property of UIView in UIKit.
If both the other options didn't work try this
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; backView.backgroundColor = [UIColor clearColor]; cell.backgroundView = backView;
This is actually answered in the docs of UITableViewCell. So while you do have to setup transparency on your controls, the actual cell background color must be set per below.
"Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it."
https://developer.apple.com/documentation/uikit/uitableviewcell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With