您的位置:首页 > 移动开发 > IOS开发

iOS - IOS8 设置TableView Separatorinset 分割线从边框顶端开始

2016-09-08 08:29 459 查看
原文链接 : http://www.cocoachina.com/bbs/read.php?tid=233228


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

}

}
http://stackoverflow.com/questions/25770119/ios-8-uitableview-separator-inset-0-not-working
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: