所以我想重寫我的UIScrolLView drawRect,但它給了我這個黑色的背景,而不是我爲我的UIScrollView指定的背景顏色。爲什麼是這樣?如果我刪除的drawRect代碼,然後一切都很好:重寫drawRect在UIScrollView黑色背景
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if (shouldDrawVerticalLineForProfile){
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef separatorColor = [UIColor colorWithRed:47.0/255.0 green:47.0/255.0
blue:47.0/255.0 alpha:1.0].CGColor;
// Add at bottom
CGPoint startPoint = CGPointMake(60, 0);
CGPoint endPoint = CGPointMake(60, 10000);
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(context, separatorColor);
CGContextSetLineWidth(context, 5.0);
CGContextMoveToPoint(context, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(context, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
}
我覺得backgroundColor屬性簡單地包裝了CGContextAddRect和CGContextFillPath,如果你做這樣的事情是什麼? – 2012-07-03 20:58:20
做點什麼? – xonegirlz
使用上面提到的兩個函數手動繪製bgcolor。 – 2012-07-03 21:05:31