解决Cell点击选中时内部Label背景颜色消失

在自定义cell的时候,在这两个方法里面都设置上UILabel的背景颜色为需要颜色即可

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Menlo}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Menlo; color: #539aa4}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Menlo; min-height: 19.0px}span.s1 {font-variant-ligatures: no-common-ligatures}span.s2 {font-variant-ligatures: no-common-ligatures; color: #c32275}span.s3 {font-variant-ligatures: no-common-ligatures; color: #3d1d81}span.s4 {font-variant-ligatures: no-common-ligatures; color: #000000}span.s5 {font-variant-ligatures: no-common-ligatures; color: #c91b13}span.s6 {font-variant-ligatures: no-common-ligatures; color: #539aa4}span.s7 {font-variant-ligatures: no-common-ligatures; color: #703daa}span.s8 {font-variant-ligatures: no-common-ligatures; color: #78492a}span.s9 {font-variant-ligatures: no-common-ligatures; color: #0435ff}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    if ([self.alertModel.alert_type isEqualToString:@"0"]) {
        self.typeLb.backgroundColor = RGBColor(0xff6600);
    }else if ([self.alertModel.alert_type isEqualToString:@"1"]){
        self.typeLb.backgroundColor = RGBColor(0x009900);
    }else if ([self.alertModel.alert_type isEqualToString:@"2"]){
        self.typeLb.backgroundColor = RGBColor(0x1583df);
    }
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    [super setHighlighted:highlighted animated:animated];
    if ([self.alertModel.alert_type isEqualToString:@"0"]) {
        self.typeLb.backgroundColor = RGBColor(0xff6600);
    }else if ([self.alertModel.alert_type isEqualToString:@"1"]){
        self.typeLb.backgroundColor = RGBColor(0x009900);
    }else if ([self.alertModel.alert_type isEqualToString:@"2"]){
        self.typeLb.backgroundColor = RGBColor(0x1583df);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容