Core Graphics是基于cpu进行渲染 , Core Animation 是基于GPU进行渲染的。
Core Graphics相对效率低,FPS很难到达60 ,容易出现卡顿;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextClipToRect(context,greenRect);
[[UIColor greenColor]set];
CGContextRestoreGState(context);
CGContextSaveGState(context);
CGContextClipToRect(context,whiteRect);
[[UIColor whiteColor]set];
[line.text drawAtPoint:whitePointWithFont:font];
CGContextRestoreGState(context);
Core Animation 效率高,流畅。
CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.KeyTimes = keyTimes;
animation.values = values;
animation.duration = duration;
animation.calculationMode = kCAAnimationLinear;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[_maskLayer addAnimation:animation forKey:@"MaskAnimation"];