//隱藏多餘的分割線
- (void)setExtraCellLineHidden:(UITableView *)tableView
{
UIView *view = [[UIViewalloc]init];
view.backgroundColor = [UIColorclearColor];
[tableView setTableFooterView:view];
}
然後在tableview創建之後,調用此方法,傳入需要設置的tableview就可以了。
//自繪分割線
- (void)drawRect:(CGRect)rect
{
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,MAINVIEWBGCOLOR.CGColor);//填充色
CGContextFillRect(context, rect);
CGContextSetStrokeColorWithColor(context,TIMINGLISTEXTRACELLLINE.CGColor);//線的顏色
CGContextStrokeRect(context,CGRectMake(AutoWHGetWidth(130), rect.size.height -1, rect.size.width,1));//線的frame
}
self.mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
在tableview創建之後,設置tableview的separatorStyle屬性即可