UITableViewCell Set Selected Image

后端 未结 5 1196
误落风尘
误落风尘 2021-02-07 08:26

trying to figure out how to set the selected image for for a tableViewCell.

The old way of writing this was cell.selectedImage but that has bee

5条回答
  •  孤独总比滥情好
    2021-02-07 08:44

    According to the Deprecated UITableViewCell Methods doc, you should use the imageView's highlightedImage property as a replacement for selectedImage. For example:

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.imageView.image = [UIImage imageNamed:@"deselected_image.png"];
    cell.imageView.highlightedImage = [UIImage imageNamed:@"selected_image.png"];
    

提交回复
热议问题