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)没有解决,留着以后再研究吧,再逼我也要自定义了

  • 相关阅读:
    centos7 & ubuntu14.02安装sublime 3
    flask之flask-restful
    ubuntu14.04安装python3.7.1
    vim中多行注释和多行删除命令
    python3之scrapy安装使用
    python3 之 linux命令实现
    ubuntu14.04安装pyspider
    升级3.4成3.6 ubuntu14.04 和miniconda虚拟环境
    python3 之初学者常犯的5个错误
    python3 之 格式化json
  • 原文地址:https://www.cnblogs.com/lilufeng/p/5056147.html
Copyright © 2011-2022 走看看