Geek
Geek

Reputation: 8320

TableViewCell color issue

I set background color to table view. Color has 30% transparency. Issue is that part of the table where there is no cell, color is displayed with transparency set. But cell is displayed with no transparency.

I don't set color in code. Table background color is set in storyboard. Please ask for any other information required.

enter image description here

Table in storyboard :

enter image description here

Code :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyCell *cell = (MyCell *) [self.tableView dequeueReusableCellWithIdentifier:CELL_IDENTIFIER forIndexPath:indexPath];

    // Set cell content
    cell.NameLabel.text = ...;
    cell.SequenceLabel.text = ...;
    cell.NumberLabel.text = ...;

    cell.backgroundColor = tableView.backgroundColor; // Also tried setting to [UIColor clearColor]

    return cell;
}

Upvotes: 2

Views: 83

Answers (4)

ratnesh
ratnesh

Reputation: 31

set the background color of the cell same as tableview background color with same transperancy, and set the tableview background color as clear color. I hope, this will be helpful.

Upvotes: 3

Taranjit
Taranjit

Reputation: 13

Hi Try using the below code & put your own RDB values :

cell.backgroundView.backgroundColor = [UIColor colorWithRed:1.0f green:2.0f blue:85.0f alpha:0.3f];

Upvotes: 2

Deep Gami
Deep Gami

Reputation: 508

You have to set cell's background clearcolor as well or if you are setting a background image of each cell than you have to use that transparent image and also set alpha of that image 0.3 so it will be transparent.

cell.backGroundColor=[UiColor ClearColor];

or you have to set alpha of your cell's backGround Color

    cell.imageView.alpha=0.3;

Upvotes: 1

Rafał Sroka
Rafał Sroka

Reputation: 40030

You are setting transparency on the table view but the cells' views are not transparent. Just set the background color of each cell to transparent.

cell.backgroundColor = [UIColor clearColor];

or set it to the same color the table view is

cell.backgroundColor = self.tableView.backgroundColor;

Upvotes: 1

Related Questions