iOS Core Graphics 和 Core Animation

来源:互联网 发布:第三次农业普查数据 编辑:程序博客网 时间:2024/05/23 02:00

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"];

0 0
原创粉丝点击