//更改tableview分割線顏色等等屬性
self.tableView.separatorColor = UIColorFromRGBA(233, 233, 233, 1);
//把tableview分割線長(zhǎng)度設(shè)為整個(gè)屏幕寬
1--
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (SystemVersion >= 7.0) {
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
if (SystemVersion >= 8.0) {
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
}
}
2——
UITableView中將分割線樣式改為None
[java] view plain copy
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
自定義UITableViewCell中復(fù)寫- (void)drawRect:(CGRect)rect方法
[java] view plain copy
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
//上分割線,
CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"ffffff"].CGColor);
CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width - 10, 1));
//下分割線
CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor);
CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1));
}