zoukankan      html  css  js  c++  java
  • iOS开发之----去除tableViewCell分割线的左边间隙,将分割线填满

    -(void)viewDidLayoutSubviews
    {
        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
        {
            [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
        }
        
        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
        {
            [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
        }
    }
    
    -(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];
        }
    }

    1、在- (void)viewDidLoad方法中调用

        [self setUpCellSeparatorInset];

    2、在当前控制器中,实现以下两个方法:

    // 设置cell的分割线左边间距为0

    - (void)setUpCellSeparatorInset

    {

        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

            [self.tableView setSeparatorInset:UIEdgeInsetsZero];

        }

        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

            [self.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];

        }

    }

  • 相关阅读:
    Qt获取程序工作目录或某路径下所有的图片或指定格式的文件
    QGraphicsView Class
    自动白平衡---灰度世界算法
    Gamma校正算法原理及实现
    QWidget,QTableWidget删除(delete)动态添加(new)的子控件释放内存
    [转]【OpenCV】OpenCV中GPU模块使用
    php之trait 个人笔记
    git 本地忽略某些个文件
    bootstrop-datatime参数配置
    mysql 一次性插入上万条数据测试专用
  • 原文地址:https://www.cnblogs.com/fs-ios/p/4705589.html
Copyright © 2011-2022 走看看