0
votes

In my TableView I use static cells. I take one section and in this section there are five cells(static cells). Now I want to make the whole section or these five cells transparent. That means I can see the Table View Controller background through the cells. How can I do that?

I have gone through many solutions. But not solved.

Edit:

May be many of you are not clear about my question. I want the cell like the below image. it is downloaded image and there will be section which is not available in this image. I am just using this image to clear the question. Look at the image the cell background is transparent.

enter image description here

5

5 Answers

2
votes

To achieve this in the most simple way possible: enter image description here

In storyboard select the static cells you want to appear transparent and select the background colour of 'Group table view background colour' or R235,G235,B241.

enter image description here

Then move the separator (the line in between) by moving it off screen by setting the below settings. enter image description here

If you still want the line ignore the above or if you want to change its colour use

override func viewDidLoad() {
            super.viewDidLoad()
tableView.separatorColor = //ADD COLOR HERE
}

Then you can add content to these cells as you would normally as I have added the label and UIImage View above.

!!However, the less simple but best way to achieve this is by creating custom cells and using dynamic prototypes. You can find many tutorials on how to do this online.

0
votes

you have to clear color to contentview of cell,also to the tableview cell and now i think you will be able to see the background and check now

0
votes

just add below code for tableview

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] init];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}
0
votes

Override your TableViewCell's awakeFromNib to set it's own background color and it's contentView's background color to clearColor:

class MyTableViewCell: UITableViewCell {

    override func awakeFromNib() {

        super.awakeFromNib()
        self.backgroundColor = .clear            
        self.contentView.backgroundColor = .clear

    }
}
0
votes

You need to set tableView with clear background color. Also tableView cell and contentView backGround color as Clear color.

For this add this Line in viewDidLoad Methods.

[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundColor:[UIColor clearColor]]; 

Add this line in cellForRowAtIndexPath Method.

cell.backgroundColor=[UIColor clearColor];
cell.contentView.backgroundColor=[UIColor clearColor];