【问题标题】:A problem when try to zoom in & out of UIButton with CAAnimationGroup尝试使用 CAAnimationGroup 放大和缩小 UIButton 时出现问题
【发布时间】:2011-05-22 10:09:11
【问题描述】:

没有动画,因为我做的不对?

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

【问题讨论】:

    标签: iphone ios core-animation caanimation


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多