簡體   English   中英

iPhone:如何在TouchesMoved事件上制作透明圖像?

[英]iPhone : How to make transparent image on TouchesMoved event?

我已經嘗試過kCGBlendModeXOR,但是透明后它變成黑色。

這是我完成的代碼,但不是我想要的。

  UITouch *touch = [touches anyObject];  
  CGPoint currentPoint = [touch locationInView:self.view];
  CGPoint lastPoint = [touch locationInView: [UIApplication sharedApplication].keyWindow];
  UIGraphicsBeginImageContext(self.view.frame.size);
  CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
  [imageView_skype.image drawInRect:rect];
  CGContextRef context = UIGraphicsGetCurrentContext();

  CGContextSetLineCap(context, kCGLineCapRound);
  CGContextSetLineWidth(context, 36.0);
  CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
  CGContextSetAlpha(context,0.10);

  CGContextSetBlendMode(context, kCGBlendModeXOR);

  CGContextBeginPath(context);

  CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
  CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
  CGContextStrokePath(context);
  imageView_skype.image = UIGraphicsGetImageFromCurrentImageContext();

你可以用口罩做到這一點

http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html

在您觸摸的事件中繪制僅黑白的蒙版圖像

並掩蓋您的原始圖像

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM