尝试放大时出现问题;使用CAAnimationGroup从UIButton中删除

时间:2011-05-22 10:09:12

标签: iphone ios core-animation caanimation

没有动画,因为我做错了吗?

-(void)swipeanimateDidStop {

    for (UIView *subview in self.swipingCell.backView.subviews){
        NSLog(@"%@",subview);
        // subview is UIButton
        [subview.layer addAnimation:[self ZoomAnimation] forKey:@"Zoom"];

    }
}

-(CAAnimationGroup *)ZoomAnimation {
    CAAnimationGroup *ZoomAnimation = [CAAnimationGroup animation];
    CABasicAnimation *In = [self zoomIn];

    ZoomAnimation.animations = [NSArray arrayWithObjects: In, nil];
    ZoomAnimation.duration = 2.0f;
    return ZoomAnimation;
}

-(CABasicAnimation *)zoomIn {
    CABasicAnimation *ZoomInAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
    ZoomInAnimation.beginTime = 0.0f;
    ZoomInAnimation.fromValue = [NSNumber numberWithFloat:20.0];
    ZoomInAnimation.toValue = [NSNumber numberWithFloat:1.0];
    ZoomInAnimation.duration = 2.0f;
    return ZoomInAnimation;
}

1 个答案:

答案 0 :(得分:1)

错误在zoomIn方法中。关键路径应为transform.scale(因为它是缩放)。

CABasicAnimation *ZoomInAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];