放大缩小动画

1.

makeImageCard = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"makeCard_Image.png"]];

    makeImageCard.frame = CGRectMake(([[UIScreen mainScreen] bounds].size.width-543/1.9)/2, self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height, 543/1.9, 998/2.36);

    makeImageCard.userInteractionEnabled = YES;

    [self.view addSubview:makeImageCard];

    

    CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

    animation.duration = 0.5;

    

    NSMutableArray *values = [NSMutableArray array];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];

    animation.values = values;

    [makeImageCard.layer addAnimation:animation forKey:nil];


2.

#pragma mark - Showing popup

- (void)showInView:(UIView *)parentView

     centerAtPoint:(CGPoint)pos

          duration:(CGFloat)waitDuration

        completion:(void (^)(void))block

{

    self.center = pos;

    self.animationCompletion = block;

    

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

    forwardAnimation.duration = self.forwardAnimationDuration;

    forwardAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.5f :1.7f :0.6f :0.85f];

    forwardAnimation.fromValue = [NSNumber numberWithFloat:0.0f];

    forwardAnimation.toValue = [NSNumber numberWithFloat:1.0f];

    

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

    reverseAnimation.duration = self.backwardAnimationDuration;

    reverseAnimation.beginTime = forwardAnimation.duration + waitDuration;

    reverseAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.4f :0.15f :0.5f :-0.7f];

    reverseAnimation.fromValue = [NSNumber numberWithFloat:1.0f];

    reverseAnimation.toValue = [NSNumber numberWithFloat:0.0f];

    

    CAAnimationGroup *animationGroup = [CAAnimationGroup animation];

    animationGroup.animations = [NSArray arrayWithObjects:forwardAnimation, reverseAnimation, nil];

    animationGroup.delegate = self;

    animationGroup.duration = forwardAnimation.duration + reverseAnimation.duration + waitDuration;

    animationGroup.removedOnCompletion = NO;

    animationGroup.fillMode = kCAFillModeForwards;

    

    [parentView addSubview:self];

    [UIView animateWithDuration:animationGroup.duration

                          delay:0.0

                        options:0

                     animations:^{

                         [self.layer addAnimation:animationGroup

                                           forKey:@"kLPAnimationKeyPopup"];

                     }

                     completion:^(BOOL finished) {

                     }];

 

}

3

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

                             animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.05, 1.05, 1)];;

                             animation.duration = 0.07;

                             animation.autoreverses = YES;

                             animation.repeatCount = 1;

                             animation.removedOnCompletion = YES;

                             animation.fillMode = kCAFillModeForwards;

                             [deletedAlert.layer addAnimation:animation forKey:nil];

                             deletedAlert.transform = CGAffineTransformMakeScale(1.0, 1.0);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值