//设置分割线的左右对齐
if([_myTableView respondsToSelector:@selector(setSeparatorInset:)]){
[_myTableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
//设置分割线的颜色
if([_myTableView respondsToSelector:@selector(setSeparatorColor:)]){
[_myTableView setSeparatorColor:[UIColor grayColor]];
}
//隐藏分割线
_myTableView.separatorStyle = NO;
//去掉多余的分割线
_myTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
#pragma mark-once 分割线 8.0以下的方法
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[tableView setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
今天复习了下UITableVie分割线的用法,看了设置分割线毛玻璃的效果,发现并没有明显突出的亮点,只是变模糊了,改颜色也没有啥用。
基本分割线很常用,随着系统的升级有些方法不兼容,要我时常兼容之前的版本,基本都是系统的或者就是自定义定义一个UIView设置1px这样做。
转载于:https://blog.51cto.com/smengxiang/2396875