zoukankan      html  css  js  c++  java
  • UITableView分割线设置

    公司UI偏爱分割线顶格,有觉得系统的颜色不好,所以敲代码的时候还得各种处理分割线,总有想掐死谁的冲动,记录一下,还是修改系统的~

    设置tableView,在viewDidLoad中写这个

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
            [tableView setSeparatorInset:UIEdgeInsetsZero];
        }
        if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
            [tableView setLayoutMargins:UIEdgeInsetsZero];
        }

    还要写这个代理方法

    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
       if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    }

    可以在这个方法里设置每个cell的分割线左边间隔,来应对UI不同的需求

    设置分割线的颜色

    _mTableView.separatorColor = Fenge_Color;
  • 相关阅读:
    为什么要用do-while(0)?
    网络字节序&大小端存储
    sql语句w3school教程
    C++编码规范
    std::deque双端队列介绍
    gdb基本操作
    gdb调试多线程
    数据库基础
    删除vector所有元素
    stl迭代器失效
  • 原文地址:https://www.cnblogs.com/lilufeng/p/5121205.html
Copyright © 2011-2022 走看看