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;
  • 相关阅读:
    Day 22 初识面向对象
    Day 21 内存处理与正则
    Day 20 常用模块(三)
    Day 18 常用模块(二)
    url解析
    jQuery---扩展事件
    jQuery---文档操作
    jQuery---属性操作
    jQuery---基本语法
    CSS---常用属性总结
  • 原文地址:https://www.cnblogs.com/lilufeng/p/5121205.html
Copyright © 2011-2022 走看看