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;
  • 相关阅读:
    8.9_java_35
    8.8_java_34
    8.7_java_33
    8.6_java_32
    8.5_java_31
    8.4_java_30
    8.3_java_29
    2020年春季学期《软件工程》教学总结
    json的标准格式
    详解 【Vue】 生命周期
  • 原文地址:https://www.cnblogs.com/lilufeng/p/5121205.html
Copyright © 2011-2022 走看看