0
您好想在我尝试着色的项目中选择颜色。 我是新来的,所以这可能是一个愚蠢的问题。我正在使用按钮来选择不同的颜色。但是,当按下按钮时,唯一发生的事情是绘制线条的最后一个像素变为所选颜色。在第一个标签下面的代码删除图纸和第二应该改变颜色为将要绘制的下一行...更改颜色
-(IBAction)buttonClicked:(UIButton *)sender {
switch (sender.tag)
{
case 1: {
drawImage.image = nil;
return;
}
//lastPoint.y -= 0;
break;
case 2: {
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 3.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 1.0, 2.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
break;
default:
break;
}
}