UIButtons イメージの一部を描画します。クリア オプションをクリックした後、ボタン イメージを最初のイメージにリセットする必要があります (描画を削除します)。setImage プロパティで UIButton の画像を設定したのですが、うまくいきませんでした。次のコードを使用して UIImage に描画します。
UIImageView *imgView =[[UIImageView alloc]init];
UIGraphicsBeginImageContext(self.frame.size);
[imgView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), self.drawingWidth);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(),lipColor.CGColor);
CGContextSetAlpha(UIGraphicsGetCurrentContext(), self.currntAlpha);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeOverlay);
imgView.image = UIGraphicsGetImageFromCurrentImageContext();
imgView.frame=CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);// Set frame for imageView
[self.imageView addSubview:imgView];
UIGraphicsEndImageContext();
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, self.bounds);
imgView.layer.shadowOffset = CGSizeZero;
imgView.layer.masksToBounds = NO;
imgView.alpha=0.05;
lastPoint=currentPoint;
self.layer.shadowOpacity=0.01;
どんな助けでも大歓迎です!!!!!!