Reputation: 10302
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:
But it renders like this (notice the absence of shadows, it's flat):
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?
Upvotes: 0
Views: 194
Reputation: 4500
UITableViewCell
.Upvotes: 0
Reputation: 49710
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:-
and its look like in project :-
Upvotes: 4