UITableViewCell 的Separator 间隔线

UITableViewCell 的Separator 间隔线,在iOS7之前它是满屏的,也就是等于width,而在iOS7开始之后,缩进了大约15像素,而在iOS7的时候增加了一个属性:

@property (nonatomic) UIEdgeInsets                    separatorInset NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED; // allows customization of the separator frame

在iOS7中可以通过设置

cell.separatorInset = UIEdgeInsetsZero;

达到间隔线满屏的效果,但是在iOS8后,这样设置又不够了,还需要设置UITableView的两个属性才可以达到满屏效果:

对于UITableView

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

    [self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

    [self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

对于 UITableViewCell

if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

    [cell setSeparatorInset:UIEdgeInsetsZero];

}

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

    [cell setLayoutMargins:UIEdgeInsetsZero];

}
posted @ 2015-10-30 15:41  沙影无痕  阅读(313)  评论(0编辑  收藏  举报