美文网首页
如何左右UITableviewCell分割线

如何左右UITableviewCell分割线

作者: Roy_Liang | 来源:发表于2017-02-22 16:33 被阅读63次
  • 满行显示分割线
  • 隐藏指定行的分割线
  • 左右分割线两端距离

1.满行显示
// 满行
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    [cell setSeparatorInset:UIEdgeInsetsZero];
}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
}

if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
   [cell setPreservesSuperviewLayoutMargins:NO];
}
2.隐藏指定行

隐藏前需先按1设置满行显示

// 隐藏分割线
if (indexPath.row == 1) {
    cell.separatorInset = UIEdgeInsetsMake(0, cell.bounds.size.width, 0, 0 );
}
3.左右两端距离
// 左右边距
cell.separatorInset = UIEdgeInsetsMake(0, 左距离, 0, 右距离 );

~ ~ ~ ~ ~ ~ end ~ ~ ~ ~ ~ ~ by Roy
--------*愿您有所收获 *


相关文章

网友评论

      本文标题:如何左右UITableviewCell分割线

      本文链接:https://www.haomeiwen.com/subject/ktemwttx.html