`

animationWithKeyPath

阅读更多

CABasicAnimation animationWithKeyPath Types

When using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to specify an animationWithKeyPath.  This is a long string and is not easily listed in the CABasicAnimation, CAPropertyAnimation, or the CAAnimation class.  I ended up finding a handy chart within the Core Animation Programming guide in Apple’s iPhone OS Reference Library.  Hope this helps save someone time, at least it will for me.

animationWithKeyPath types

//The following code moves a view up 60 pixels and stops.

CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
theAnimation.delegate = self;
theAnimation.duration = 1;
theAnimation.repeatCount = 0;
theAnimation.removedOnCompletion = FALSE;
theAnimation.fillMode = kCAFillModeForwards;
theAnimation.autoreverses = NO;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:-60];

[self.view.layer addAnimation:theAnimation forKey:@"animateLayer"];
分享到:
评论

相关推荐

    通过 ViewController+Category 的方式实现类似电商等项目中-XX3DRiseAndFall.zip

    CABasicAnimation *riseAndFallAnim = [CABasicAnimation animationWithKeyPath:@"position.z"]; riseAndFallAnim.fromValue = @(-5); riseAndFallAnim.toValue = @(5); riseAndFallAnim.duration = 2.0; // ...

    core animation cook book

    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotation.fromValue = @0; rotation.toValue = @M_PI_2; rotation.duration = 1.0; rotation.repeatCount = HUGE_...

    在 iOS 上绘制多个图层 的工具_Objective-C_代码_下载

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; animation.fromValue = [NSValue valueWithCGPoint:layer.position]; animation.toValue = [NSValue valueWithCGPoint:new...

    官网生成libzbar.a,代码完整,一分钟搞定扫码

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"]; // 设置动画参数... [scanLine addAnimation:animation forKey:@"animatePath"]; ``` 最后,别忘了在你的主项目中链接生成的...

    iOS随机冒泡

    2. **CAKeyFrameAnimation的创建**:通过`+[CAKeyframeAnimation animationWithKeyPath:]`方法创建一个关键帧动画对象,并指定动画影响的属性,如`position`(位置)、`transform`(变换)等。 3. **关键帧设置**:...

    CAKeyframeAnimation动画(UILabel左右晃动)OC 版

    CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; ``` 接下来,定义动画的关键帧。这里我们使用`CGAffineTransformMakeTranslation`来生成每个关键帧的位置: ```...

    ios-吸附小球(仿《知乎》登录效果).zip

    3. **自定义动画(Custom Animation)**:为了实现吸附效果,可能需要自定义动画类,继承自`CAAnimation`,并重写`+ (id)animationWithKeyPath:(NSString *)path`方法,以便控制小球在接近目标时的行为。 4. **...

    简单的3D动画效果

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; animation.duration = 5.0; animation.values = @[ [NSValue valueWithCATransform3D:CATransform3DIdentity], ...

    animation动画效果

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; animation.fromValue = [NSValue valueWithCGPoint:view.layer.position]; animation.toValue = [NSValue valueWithCGPoint:...

    iphone范例代码 swap anim

    因此,合理使用`animationWithKeyPath:`选择影响性能最小的属性进行动画,以及利用`shouldAnimatePropertyWithKey:`来优化不必要的动画。 7. **互动性**:在某些情况下,我们希望动画可以响应用户的触摸事件。在...

    iOS实现循迹动画

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; animation.path = path.CGPath; animation.duration = 5.0; // 动画持续时间 animation.fillMode = ...

    (0084)-iOS/iPhone/iPAD/iPod源代码-动画(Animation)-GraphicsAnimation

    - 如果系统提供的动画不能满足需求,可以创建自定义动画类继承自`CAAnimation`,并覆写`+ (id)animationWithKeyPath:(NSString *)path`方法来指定动画影响的属性。 10. **动画组(Animation Groups)**: - `...

    iOS:利用帧图实现动画效果

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; animation.values = frames; animation.keyTimes = [NSArray arrayWithObjects:@... // 填充适当的时间值 animation....

    图层CALayer的一些知识

    1. **基本动画**:使用`+[CAAnimation animationWithKeyPath:]`创建基于属性的关键路径动画。例如,改变图层的位置、透明度或尺寸,可以通过`"position"`、`"opacity"`或`"bounds.size"`等键路径来实现。 2. **动画...

    IOS 中基于layer的相关动画

    可以使用`+[CABasicAnimation animationWithKeyPath:]`来创建一个基本动画,并设置其属性,如duration、timingFunction等。 2. **关键帧动画(Keyframe Animation)** 关键帧动画允许你在动画过程中定义多个关键...

    iphone应用之微信摇一摇效果

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"]; // 设置关键路径,添加动画细节... [imageView.layer addAnimation:animation forKey:@"shakeAnimation"]; ``` ...

    iOS常用动画

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds.origin.y"]; animation.duration = 1.0; animation.repeatCount = INFINITY; animation.autoreverses = YES; manImageView.layer....

    SKBounceAnimation:CAKeyframeAnimation 子类,可让您快速轻松地设置反弹次数、开始和结束值,并为您创建动画

    SKBounce动画 SKBounceAnimation是一个CAKeyframeAnimation子类,它根据...SKBounceAnimation *bounceAnimation = [SKBounceAnimation animationWithKeyPath:keyPath]; bounceAnimation.fromValue = [NSNumber numbe

    ForAnimation:CALayer的各种动画效果

    ForAnimationCALayer的各种动画效果IntroduceIOS--CALayer实现,界限、透明度、位置、旋转、缩放组合动画基于框架:QuartzCore.framework//抖动CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@...

    iOS动画-定时对UIView进行翻转和抖动的方法

    CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation....

Global site tag (gtag.js) - Google Analytics