【发布时间】:2013-02-27 21:29:47
【问题描述】:
我想制作一个矩形并用颜色填充。但是我的代码不起作用(没有出现矩形)。请告诉我这段代码有什么问题?
- (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);
}
}
if 语句是一个圆圈。
【问题讨论】:
-
“它不起作用”是什么意思?
-
我实际上通过删除第一个 CGCOntextDrawPath 行解决了这个问题。但请查看更新后的问题,有新问题。