zoukankan      html  css  js  c++  java
  • 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:



  • 相关阅读:
    Apache Common-IO 使用
    Apache Compress-使用
    使用JavaConfig方式-Spring 基础学习
    设计模式-策略模式
    logback mybatis 打印sql语句
    oracle 迭代查询
    使用 Dom4j 将 XML 转换为 MAP
    Java连接Access数据库的那些坑
    如何从Maven中央存储库下载?
    sublime构建各个编译环境
  • 原文地址:https://www.cnblogs.com/feiling/p/4789097.html
Copyright © 2011-2022 走看看