Skip to content

CAKeyframeAnimation动画怎么搞? #27

@vitasapple

Description

@vitasapple

比如这个震动效果的动画要怎么写?

    CAKeyframeAnimation * anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    anim.values = @[[NSValue valueWithCGPoint:CGPointMake(targetV.center.x, targetV.center.y)],
                    [NSValue valueWithCGPoint:CGPointMake(targetV.center.x, targetV.center.y + 1)],
                    [NSValue valueWithCGPoint:CGPointMake(targetV.center.x+1, targetV.center.y - 1)],
                    [NSValue valueWithCGPoint:CGPointMake(targetV.center.x-1, targetV.center.y + 1)]];
    anim.duration = 0.2;
    anim.repeatCount = 5;
    anim.removedOnCompletion = YES;
    [targetV.layer addAnimation:anim forKey:@"shake"];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions