Change UITableView cell selection style to red

I need to change the default UITableView cell selection style from blue to red. Can someone help me with this?

+4
source share
4 answers

You can try setting the selectedBackgroundView.image cells, for this tutorial . This would give you the opportunity to create a beautiful image based on the gradient.

+5
source

You do not need an image or subclass of the cell. Just create a cell in the TableView: cellForRowAtIndexPath table:

  cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; cell.selectedBackgroundView.backgroundColor = [UIColor redColor]; 
+11
source

If you are a subclass of UITableViewCell, you can change its selected and selected user interface behavior by overriding the following methods.

 - (void)setSelected:(BOOL)selected animated:(BOOL)animated; - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated; 

For instance:

 - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { [super setHighlighted:highlighted animated:animated]; if (highlighted) { self.backgroundColor = [UIColor redColor]; } else { self.backgroundColor = [UIColor blackColor]; } } 
+3
source
 UIImageView *selectedBackground = [[UIImageView alloc] initWithFrame:self.view.frame]; selectedBackground.backgroundColor = [UIColor redColor]; [cell setSelectedBackgroundView:selectedBackground]; 

you can try something like this

0
source

Source: https://habr.com/ru/post/1347031/


All Articles