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];

        }

    }

  • 相关阅读:
    [转]TOP 1比不加TOP慢的疑惑
    .ETL构建数据仓库五步法
    MySQL与Oracle的语法区别
    MySQL的表分区
    ORACLE分区表的使用和管理
    Oracle与MySQL的几点区别
    数据仓库超级大表分区方式改变
    Windows平台下MySQL常用操作与命令
    PowerDesigner使用教程 —— 概念数据模型
    MYSQL千万级数据量的优化方法积累
  • 原文地址:https://www.cnblogs.com/fs-ios/p/4705589.html
Copyright © 2011-2022 走看看