Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C: How to make background color of UITableView Consistent

I have been trying to set the background color of my table view but am facing an issue

This is what I am trying to do.

//Set background color of table view (translucent)
self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7];

//Set frame for tableview
[self.tableView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.picker.frame.size.height)];

After setting the table cells, I saw that there is an inconsistency in the alpha level around the table view cell (see screenshot below)

tableView BackgroundColor

Is there anyway to make the color / alpha level consistent for the background? (Note: I am not setting a background image, only color and alpha level)

Thanks!

Zhen Hoe

like image 491
Zhen Avatar asked May 19 '11 02:05

Zhen


People also ask

How to set background color in objective C?

backgroundColor =[UIColor colorWithRed:178/255.

How do I change the color of a Tableview selection?

you can just change the backgroundView's backgroundColor property like so: cell. selectedBackgroundView?. backgroundColor = <your color .

How do I change the background color in a table?

For changing the background color of the table view cell, you should change the contentView. backgroundColor property of the cell. Now run the project to see the effect.


2 Answers

I recently ran into this problem myself and think I found the solution

self.tableView.backgroundColor = [UIColor clearColor];
self.parentViewController.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7];

Give that a shot, might need some massaging for your specific case (looks like you have some picture behind that translucent blue too).

like image 99
ACBurk Avatar answered Nov 15 '22 07:11

ACBurk


You need to make the background of the UITableView clear as well as set Opaque to FALSE

[self.tableView setBackgroundColor: [UIColor clearColor]];
[self.tableView setOpaque: NO];
like image 25
WrightsCS Avatar answered Nov 15 '22 08:11

WrightsCS