Home Tutorial Iphone Examples UITableView Background Color

 
 

Share on Google+Share on Google+
UITableView Background Color
Posted on: August 9, 2010 at 12:00 AM
Advertisement
To change the background color of UITableView in iPhone application, you just need to write the given line of code into the tableView cellForRowAtIndexPath.

UITableView Background Color

To change the background color of UITableView in iPhone application, you just need to write the given line of code into the tableView cellForRowAtIndexPath.

tableView.backgroundColor = [UIColor grayColor];

The above line will change the default background color into gray color. You can also set the gradient to it.

In this example we are simply changing the color of all the cells or table view background. But you can also draw different styles to it.. table view also provides properties that allows you to add image at background.

On building the application it should look like the given image..


In the image two you can see that on click, cell is showing different color or highlighted. This can be done by setting the cell color on click.

//To Set Selected Background Color
UIImageView *selectedBackground = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320,100)];
selectedBackground.backgroundColor = [UIColor orangeColor];
[cell setSelectedBackgroundView:selectedBackground];

Download Code

Advertisement

Related Tags for UITableView Background Color:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com