I have a UITableViewCell
subclass with the following drawRect:
implementation. It will draw a line at the bottom of the cell, indented by 30 points to match our design. The tableView.separatorStyle
is set to UITableViewSeparatorStyleNone
in lieu of this custom drawing.
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
if (!_hideBottomLine) {
CGContextRef ref = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(ref, NO);
CGContextSetStrokeColorWithColor(ref, [UIColor colorWithWhite:0.75 alpha:1].CGColor);
CGContextSetLineWidth(ref, 1);
CGContextMoveToPoint(ref, 30, CGRectGetMaxY(rect));
CGContextAddLineToPoint(ref, CGRectGetMaxX(rect), CGRectGetMaxY(rect));
CGContextStrokePath(ref);
}
}
This worked great in iOS 6 and on iOS 7 when built with the iOS 6 SDK. Now that I am building with the iOS 7 SDK the line does not appear.
Am I missing some change with CG drawing in the iOS 7 SDK?
EDIT:
So I now realize there is a better way to do this in iOS 7 using cell.separatorInset
, I also found some other similar CG code I had written that works. So I think the issue is isolated to implementing drawRect:
on UITableViewCell
I'd still like an answer on how to do custom drawing on the cell in iOS 7 though.