码迷,mamicode.com
首页 > 移动开发 > 详细

iOS设置分割线从边框顶端开始

时间:2015-09-15 16:13:22      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

好方法,本来是在xib里面设置自定义分割线位置,结果还是差15像素,该方法亲测好使。

IOS8 设置TableView Separatorinset 分割线从边框顶端开始 (转)

在ios8上 [TableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];不起作用

经过测试加入下面方法 在ios7 8上都可以正常工作
    -(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];  
        }  
    }  

 


对于多余的横线,如果显示不到全屏,会出现横线。

只需要设置为 

UITableViewStyleGrouped

 

iOS设置分割线从边框顶端开始

标签:

原文地址:http://www.cnblogs.com/6duxz/p/4810420.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!