У меня есть такое меню:
Нормальным (невыделенным) состоянием для каждой ячейки является изображение, выбранное состояние также является изображением (похоже на синий цвет по умолчанию). Тем не менее, я хотел бы добавить дополнительное третье изображение, так что, когда пользователь выбирает ячейку, он кратковременно изменяется на этот третий цвет перед тем, как идти синим (выбранным).
Это мой код:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView setBackgroundColor:[UIColor clearColor]];
NSString *cellIdentifier = @"MenuItemCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
UIImage *cellBackgroundNormal = [UIImage imageNamed:@"cell_menu_normal"];
UIImage *cellBackgroundSelected = [UIImage imageNamed:@"cell_menu_selected"];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:cellBackgroundNormal];
UIImageView *cellBackgroundSelectedView = [[UIImageView alloc] initWithImage:cellBackgroundSelected];
cell.backgroundView = cellBackgroundView;
cell.selectedBackgroundView = cellBackgroundSelectedView;
[cell.textLabel setBackgroundColor:[UIColor clearColor]];
[cell.textLabel setTextColor:[UIColor whiteColor]];
[cell.textLabel setFont:[UIFont boldSystemFontOfSize:17.0]];
cell.textLabel.text = [self.menuItems objectAtIndex:indexPath.row];
return cell;
}
Как вы можете видеть, на данный момент у меня только два состояния. Я не вижу, как я могу представить какой-то cell.hoveredBackgroundView
для третьего изображения. Если кто-то может помочь мне реализовать это, я бы очень признателен.