I'm using the following code in my subclass of UITableViewCell
to set a drop shadow for unselected cells in my UITableView
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[super setHighlighted:highlighted animated:animated];
[self applyLabelDropShadow:!highlighted];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
[self applyLabelDropShadow:!selected];
}
- (void)applyLabelDropShadow:(BOOL)applyDropShadow
{
self.textLabel.shadowColor = applyDropShadow ? [UIColor whiteColor] : nil;
self.textLabel.shadowOffset = CGSizeMake(0, 1);
self.detailTextLabel.shadowColor = applyDropShadow ? [UIColor whiteColor] : nil;
self.detailTextLabel.shadowOffset = CGSizeMake(0, 1);
}
This code from another StackOverflow question by Mike Stead and it works fine.
When the row moves from selected to deselected however, you can see the detailTextLabel
shift down very slightly which I don't want to happen. This doesn't happen to the textLabel
for the cell.
Any ideas why?