-1
我想用颜色填充矩形。但我的代码不起作用(没有矩形出现)。请告诉我这段代码有什么问题?无法为CGRect设置填充颜色/路径石英
- (void)drawRect:(CGRect)rect
{
context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 84, 84, 84, 1);
firstTower = CGRectMake(20, 20, 50, 200);
CGContextDrawPath(context, kCGPathFillStroke);
if (_touchHasBegun)
{
context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetRGBStrokeColor(context, 0, 34, 102, 1);
CGContextSetRGBFillColor(context, 135, 206, 250, 0.25);
rectangle = CGRectMake(1, 1, 500, 500);
CGContextAddArc(context, pointWhereUserClickedX, pointWhereUserClickedY, 50, 0, 2*3.14159265359, YES);
CGContextDrawPath(context, kCGPathFillStroke);
}
}
如果语句是一个圆。
“不起作用”是什么意思? – 2013-02-27 21:36:57
我实际上通过删除第一个CGCOntextDrawPath行来解决这个问题。但请看一个新问题的更新问题。 – JimmyYXA 2013-02-27 21:57:54