zoukankan      html  css  js  c++  java
  • 设置UITableView背景透明/监听cell左边的删除按钮的点击事件

        _tableView = [[UITableView alloc] init];
        _tableView.delegate   = self;
        _tableView.dataSource = self;
      
    _tableView.frame = CGRectMake(kZero, 66, kScreenW, kScreenH - 66 - 70);
      //设置列表为透明背景
        UIImage *image = [MusicManager createImageWithColor:[UIColor clearColor]];
        _tableView.backgroundView  = [[UIImageView alloc] initWithImage:image];
        _tableView.backgroundColor = [UIColor clearColor];
        
    #pragma mark    设置UITableView背景的代理方法
    -(void)tableView:(UITableView*)tableView  willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
    {
        [cell setBackgroundColor:[UIColor clearColor]];
    }
    
    #pragma mark   点击cell左边的删除按钮时触发
    - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
     
        //获取当前处于删除状态的cell
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
        //获取cell中所有的子控件
        NSArray *labelArray = cell.contentView.subviews;
        for (UIImageView *view in labelArray) {
            if (view.tag == 3) {//向右的图片
                CGRect temp = view.frame;
                temp.origin.x = 255;
                view.frame = temp;
            }
        }
        return @"删除";
    }
    
  • 相关阅读:
    如何配置MySQL
    软件工程第三次作业
    软件工程第二次作业
    软件工程第一次作业
    Python 【面试总结】
    Vue【你知道吗?】
    Python 【面试强化宝典】
    Python 【基础面试题】
    Vue 【前端面试题】
    Redis 【常识与进阶】
  • 原文地址:https://www.cnblogs.com/hw140430/p/3889580.html
Copyright © 2011-2022 走看看