有时候,我们在使用tableview 的时候会发现,想要的效果,可能不是原生的,tableView 的原生的分割线并不是完成的填充在两边的,而有时候我们需要的就是完全的分割线,这时候我们就需要处理一些事情
一:隐藏多余的分割线,
[self setExtraCellLineHidden:tableView];
- (void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view = [UIView new];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
}
这其实就相当于把分割线给设置成透明的
二:设置分割线的样式,粗细,以及分割线的颜色
[_tableView setSeparatorColor:[UIColor redColor]];
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
同时,分割线的种类也是一个枚举值,通常来说一般是具有以下三种样式
typedef NS_ENUM(NSInteger, UITableViewCellSeparatorStyle) {
UITableViewCellSeparatorStyleNone, //没有分割线
UITableViewCellSeparatorStyleSingleLine, // 细线的分割线
UITableViewCellSeparatorStyleSingleLineEtched // This separator style is only supported for grouped
iOS开发中tableView的分割线的处理问题
最新推荐文章于 2023-04-25 10:40:55 发布