• iOS开发-为UITableViewCell添加横线


    在开发过程中经常会遇到设计稿中Cell分割线样式和系统自带的样式差别很大,如何实现这里做下总结,主要包括如下两步:

    1. 取消TableView默认的分割线样式

    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    

    2. 为TableViewCell添加背景图片

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = (UITableViewCell *)[_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            // 为cell设置背景图片,是一张的上下横线,中间空白的背景图片
            cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage resizedImage:@"exitGroupButton.png"]];
        }
        
        cell.imageView.image = [UIImage imageNamed:@"profile_setting@2x.png"];
        cell.textLabel.text = @"设置";
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }
    
    exitGroupButton.png:



  • 相关阅读:
    绘图QPainter-画刷
    绘图QPainter-画笔
    pyqt5-多线程QThread类
    升级时出现错误的解决办法
    打包pyinstaller
    多文档界面QMdiArea
    停靠窗口QDockWidget
    堆叠窗口QStackedWidget
    VC运行库版本不同导致链接.LIB静态库时发生重复定义问题的一个案例分析和总结
    【一】ODB
  • 原文地址:https://www.cnblogs.com/feiling/p/4789097.html
Copyright © 2020-2023  润新知