iPhone:How to set background image for tablerow cell?
- by user187532
Hello all,
I want to put some background image for TableView row cell. I am using the following code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
.....................
...................
UIImage * backgroundImage = [UIImage imageNamed:@"cell.png"];
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
cell.opaque = NO;
cell.contentView.opaque = NO;
cell.backgroundColor = [UIColor clearColor];
cell.backgroundColor = backgroundColor;
//cell.contentView.backgroundColor = [UIColor clearColor];
//cell.contentView.backgroundColor = backgroundColor;
}
But it is not giving the background image properly. Could someone guide me what is the proper ways of setting background image for a tableview row?
Note: I'm also setting background image for my TableView as well using the below code:
UIImage * backgroundImage = [UIImage imageNamed:@"Tablebackground.png"];
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
self.myTableView.backgroundColor = [UIColor clearColor];
self.myTableView.alpha = 0.9;
self.myTableView.backgroundColor = backgroundColor;
I don't observe any problem for tableview background. Only thing here is, tableview background image is not being static, when scrolling happening, image is also scrolling.
But i want to know first how to set background image for Tableview row cell?
Thank you.