UITableViewCell: How to prevent blue selection background w/o borking isSelected property?

后端 未结 6 1085
予麋鹿
予麋鹿 2020-12-04 08:03

I have a custom UITableViewCell subclass. I have set the contentView of my cell subclass to a custom UIView class in which i am overr

6条回答
  •  旧时难觅i
    2020-12-04 09:04

    You must also override setHighlighted: to prevent the blue gradient from ever showing. If you just override setHighlighted: then you end up with a momentary selection effect.

    so you'll have these two methods:

    - (void)setHighlighted: (BOOL)highlighted animated: (BOOL)animated
    {
        // don't highlight
    }
    
    - (void)setSelected: (BOOL)selected animated: (BOOL)animated 
    {
        // don't select
        //[super setSelected:selected animated:animated];
    }
    

提交回复
热议问题