IOS tableViewCell設(shè)置分割線(xiàn)
//1.比如我們只需要顯示固定的幾行cell,去掉底部多余的表格線(xiàn)
[tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
// 2.1在代理方法中設(shè)置cell分割線(xiàn) 頂頭顯示
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"myCell"];
}
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.2.在自定義tableViewCell中設(shè)置分割線(xiàn) 頂頭顯示
// self代表cell。
if ([self respondsToSelector:@selector(setSeparatorInset:)]) {
[self setSeparatorInset:UIEdgeInsetsZero];
}
if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
[self setLayoutMargins:UIEdgeInsetsZero];
}
if([self respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
[self setPreservesSuperviewLayoutMargins:NO];
}