iOS里动画那种方式效率比较高
我在做一个像Path那种向右滑动,显示出一个导航菜单。
我用过两种方式,一种是
[UIView beginAnimations:nil context:@"view_animation"]; [UIView setAnimationDuration:0.3]; self.view.left = 200.0f; // setLeft 是我自己定义的方法 [UIView commitAnimations];
另一种:
self.view.layer.anchorPoint = CGPointZero; self.view.layer.frame.left = 200.0f; CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.duration = 0.3f; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(0.0f, 0.0f)]; [path addLineToPoint:CGPointMake(200.0f, 0.0f)]; pathAnimation.path = path.CGPath; pathAnimation.calculationMode = kCAAnimationLinear; [self.view.layer addAnimation:pathAnimation forKey:@"view_animation"];
但是这两种方法,貌似都有一点点卡。而且最近,我更新了网易新闻的客户端,网易新闻的客户端这个操作非常流畅,有可能是怎么实现的呢?
anonym
11 years, 2 months ago