I have a grouped tableview where I have one row in each section. I am setting the backgroundview of the cell to my custom image and I wish the row is rendered this way:
![](https://www.manongdao.com/static/images/pcload.jpg)
But it renders like this (notice the absence of shadows, it's flat):
![](https://www.manongdao.com/static/images/pcload.jpg)
Here's the code in cellforRowAtIndexPath:
((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"BGImage"];
Where BGImage is the first image in this post, with shadows. What am I missing here?
you have to set Your Cell Background using bellow Delegate Method of UITableView:-
- (void)tableView: (UITableView*)tableView
willDisplayCell: (UITableViewCell*)cell
forRowAtIndexPath: (NSIndexPath*)indexPath
{
UIImage *img = [UIImage imageNamed:@"yourImage.png"]; // get your background image
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage: img];
cell.backgroundColor = backgroundColor;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
}
at your issue may be your image Height
width
and your cell height
width
not same
I am using above method in my project set with bellow shaded image set in Cell:-
![](https://www.manongdao.com/static/images/pcload.jpg)
and its look like in project :-
![](https://www.manongdao.com/static/images/pcload.jpg)