CGContext を使用して UIBezierPath 曲線描画のストロークの色を変更するために別のボタンを使用していますが、色を変更すると、以前に描画された線も最後のストロークの色に従って色が変わります。しかし、以前に描画された線の色を変更したくありません。どんな助けでも大歓迎です。次のコードを使用しました。
(void)drawRect:(CGRect)rect{
if(colorwith==1){
CGContextRef bluecontext = UIGraphicsGetCurrentContext();
CGContextBeginPath(bluecontext); // clears any previous path
CGContextSetRGBFillColor(bluecontext, 0.2, 0.3, 0.5, .06);
CGContextSetStrokeColorWithColor(bluecontext, [UIColor blueColor].CGColor);
CGContextStrokePath(bluecontext); // draw blue line
for(UIBezierPath *_tempPath in _arrayForOperationPath)
{
[_tempPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
//[[UIColor blackColor]setStroke];
}
else if (colorwith==2){
CGContextRef bluecontextt = UIGraphicsGetCurrentContext();
CGContextBeginPath(bluecontextt); // clears any previous path
CGContextSetRGBFillColor(bluecontextt, 0.2, 0.8, 0.7, .01);
CGContextSetStrokeColorWithColor(bluecontextt, [UIColor redColor].CGColor);
CGContextStrokePath(bluecontextt);
// [[UIColor redColor]setStroke];
for(UIBezierPath *_tempPath in _arrayForOperationPath)
{
[_tempPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
//[[UIColor blackColor]setStroke];
}
}