我想用紅色填充路徑。這是我的代碼:用特定顏色填充路徑
CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
CGContextBeginPath(c);
CGContextSetStrokeColor(c, red);
CGContextSetFillColorWithColor(c, [UIColor whiteColor].CGColor);
CGContextMoveToPoint(c, 10, 10);
CGContextAddLineToPoint(c, 20, 20);
CGContextAddLineToPoint(c, 20, 40);
CGContextAddLineToPoint(c, 40, 20);
CGContextAddLineToPoint(c, 10, 10);
CGContextStrokePath(c);
CGContextFillPath(c);
我知道,我必須使用CGContextSetFillColor()
和CGContextFillPath()
,但它不工作。
我該如何正確地做到這一點?
你能否提供你正在使用以試圖填補代碼路徑? – 2012-04-26 18:58:54
@craig當然,我編輯第一篇文章 – 2012-04-26 19:12:13
解決。在第一篇文章中回答。 – 2012-04-26 19:25:50