Search code examples
iosxcodeanimationsubviewscaletransform

ios CATransform3DMakeScale scaleup animation


I have the following animation:

CATransform3D scaleTransform = CATransform3DMakeScale(0.1,0.1, 1.0);
scaleAnimation.toValue = [NSValue valueWithCATransform3D:scaleTransform];
keyframeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];;

where I'm scaling down a subview. But I'm trying to do opposite. start from .01% of the size of the subview and go to 100% of the size of the subview. Does anyone knows how can I do this?


Solution

  • Do this:

    yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01);
    [UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 
    //change time duration according to requirement
    // animate it to the identity transform (100% scale)
    yourSubView.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished){
    // if you want to do something once the animation finishes, put it here
    }];