How to change color of UITableViewCell when selecting?

前端 未结 14 2520
予麋鹿
予麋鹿 2020-12-04 10:59

I have a menu like so:

\"Menu\"

The normal (unselected) state for each cell is an image, the selected s

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 11:25

    Try this in custom cell-

    - (void)awakeFromNib
    {
        UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:self.bounds];
        selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        selectedBackgroundView.backgroundColor = [UIColor colorWithRed:246.0/255.0 green:95.0/255.0 blue:22.0/255.0 alpha:1.0];
        self.selectedBackgroundView = selectedBackgroundView;
    }
    

提交回复
热议问题