在核心animation或核心graphics上创build简单的橡皮擦效果有多困难?
嗨,我想创build一个橡皮擦animation或核心graphics看起来像摩擦当前的内容,并添加一个新的内容,当我点击视图或button上的一个uibutton。
是否很难做到这一点,任何教程或网页链接,以显示如何做到这一点?
嗨,我们可以使用这个橡皮擦function核心animation在我们的应用程序如下:
CGPoint currentPoint = [touch locationInView:imgBlankView]; UIGraphicsBeginImageContext(self.view.frame.size); [imgBlankView.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, imgBlankView.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(),lineWidth); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint1.x, lastPoint1.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); imgBlankView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); lastPoint1 = currentPoint;
使用这个代码来清除你用核心animation(如圆形,矩形或任何CALayer)绘制的溺水,就像用这个代码淹没一样。
把这个代码放在你的触摸移动方法中,并根据用户触及的视图,使用此代码擦除该代码享受擦除function。
- 自定义UITableViewCell高度会导致不正确的animation
- buttonanimation像ios游戏中心button
- 等待animation在iOS中完成?
- 如何使我的UIBezierPathanimation与CAShapeLayer?
- 在UIView子类中使用的CAShapeLayer不起作用
- (Swift)如何(animation)显示/隐藏单元格基于UITextfieldinput通过重新加载UITableView?
- iOS核心animation:CALayer bringSublayerToFront?
- 如何自定义模态视图控制器呈现animation?
- 使用90%CPU的UIViewanimation