zoukankan      html  css  js  c++  java
  • 修改UITableview多选按钮

    项目里用到UITableview的编辑效果,需要更改左边选择的图片(如下图),我又是个忠于原生控件(懒得自定义)的人,系统没有给改变的api,所以又用了偷梁换柱啊

    以下是我在cell里面打印的cell.subviews, UITableViewCellEditControl就是左边的图片,取到里面的UIimageView更改图片就可以了

    下面贴代码:

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        [super setSelected:selected animated:animated];
        if (self.isEditing && self.isSelected) {
            UIControl *control = [self.subviews lastObject];
            UIImageView * imgView = [[control subviews] objectAtIndex:0];
            imgView.image = [UIImage imageNamed:@"选中icon1"];
        }
        // Configure the view for the selected state
    }

    这样有遇到一个问题,就是高亮状态下图片还是系统默认的,所以我又写了如下代码处理高亮情况

    - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
        [super setHighlighted:highlighted animated:animated];
        if (self.isEditing && self.isHighlighted ) {
            UIControl *control = [self.subviews lastObject];
            UIImageView * imgView = [[control subviews] objectAtIndex:0];
            imgView.image = [UIImage imageNamed:@"选中icon1"];
        }
        
    }

    这样高亮情况显示问题解决了,还有一个隐藏的问题(TouchUpinside)没有解决,留着以后再研究吧,再逼我也要自定义了

  • 相关阅读:
    Vue在移动端App中使用的问题总结
    CSS中的自适应单位vw、vh、vmin、vmax
    sass、less中的scoped属性
    CSS中的 , > + ~
    Git 使用的问题总结
    Vux的安装使用
    React-router的基本使用
    React使用的扩展
    React使用的思考总结
    React的基本使用
  • 原文地址:https://www.cnblogs.com/lilufeng/p/5056147.html
Copyright © 2011-2022 走看看