# 改变iOS7上tableview的分割线长、颜色问题
if ([ self . tableView respondsToSelector : @selector (setSeparatorInset:)]) {
[ self . tableView setSeparatorInset : UIEdgeInsetsZero ];
[ self . tableView setSeparatorColor : kGetColor ( 18.0 , 18.0 , 18.0 )];
}
#去掉UITableView中的某cell条分割线
if (cell == nil ) {
cell = [[ UITableViewCell alloc ] initWithStyle :UITableViewCellStyleDefault reuseIdentifier :cellIdentifier];
[cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 10000000)];
}
#或
if (indexPath. section == 0 && indexPath. row == 1 ) {
[cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 10000000)];
}
自定义分割线:
UITableView中将分割线样式改为None
tableView.separatorStyle = UITableViewCellSeparator<wbr>StyleNone;</wbr>
自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法
- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentCont<wbr>ext(); CGContextSetFillColorWit<wbr>hColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect); //上分割线, CGContextSetStrokeColorW<wbr>ithColor(context, [UIColor colorWithHexString:@"ffffff"].CGColor); CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width - 10, 1)); //下分割线 CGContextSetStrokeColorW<wbr>ithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor); CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1)); }</wbr></wbr></wbr></wbr>