开发者

A problem when try to zoom in & out of UIButton with CAAnimationGroup

开发者 https://www.devze.com 2023-03-07 08:22 出处:网络
no have animation , cause i do it incorrect ? -(void)swipeanimateDidStop { for (UIView *subview in self.swipingCell.backView.subviews){

no have animation , cause i do it incorrect ?

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

    ZoomAnimatio开发者_开发技巧n.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;
}


The error is in zoomIn method. The key path should be transform.scale (since it is zoom).

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

精彩评论

暂无评论...
验证码 换一张
取 消