drawRect代码如下:
-(void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef cxt = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(cxt, 2.0);
CGContextSetStrokeColorWithColor(cxt, [UIColor redColor].CGColor);
CGContextMoveToPoint(cxt, 250.0 , 0.0);
CGContextAddLineToPoint(cxt, 250.0, 50.0);
CGContextStrokePath(cxt);
}
会画出红色的线。但是一设置cell的背景线就会消失。设置背景的代码:
UIView *view = [[UIView alloc] initWithFrame:cell.frame];
view.backgroundColor = [UIColor grayColor];
cell.backgroundView = view;
怎么回事?为什么背景会隐藏起来红线呢?谢谢您的解答。