UITableViewCell color issues with custom table view background

I have a UITableView with a custom background image set as follows:

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]]; 

The background looks fine, but my UITableViewCells (the default cells, not the custom ones) have a strange shade for them, and the UILabel containing the text "New Project" also seems to have some kind of background. How can i remove this? I have already tried:

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

thanks

alt text http://cl.ly/Cg5/content

+6
iphone cocoa-touch uilabel uitableview
source share
3 answers

I find this to be an unpleasant side effect of simply adding an image directly to your tableview backgroundColor.

Try adding an image to the background color of the view :

 [[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]]]; 

and then set the backgroundColor table view :

 [[self tableView] setBackgroundColor:[UIColor clearColor]]; 

Hope this helps!

+2
source share

Several times, when you work with customizing images for an application and testing on a simulator, they freeze in the application for several launches. Not sure if this is the case even if you delete image files; they still keep popping up.

I would say that you leave the simulator and restart Xcode. Then force complete the recovery of the application on the simulator. This should clear any images - even background images if they are still referenced.

If this is not a solution that works ... try to make sure that you do not have conflicting commands going to the same UiTablView object - (1 from IB and 1 from Xcode programmatically). Sometimes you may lose sight of the fact that you have installed something in IB, and this is contrary to what you tell him to do this in programming.

If this does not solve the problem ... check the connections in IB and make sure that you have restored the correct appearance of the IBOutlet UITableView * table. And you have a delegate and data protocols in the header.

0
source share

If you want each cell to be set with a background and want to remove the text background, maybe you can try this ...

 - (void)viewDidLoad { ... self.tableView.backgroundColor = [UIColor clearColor]; ... } - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { ... cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]]; cell.textLabel.backgroundColor = [UIColor clearColor]; ... } 
0
source share

All Articles