动画 -- 从某个定点开始放大某个视图

参考:

https://blog.csdn.net/yongyinmg/article/details/37927833

https://www.jianshu.com/p/a5cd9ba42bad

从某个定点开始放大某个视图

- (void)animateApplyToView:(UIView *)view {
    
    NSString *keyPath = @"transform.scale";
    CABasicAnimation *animationScale = [CABasicAnimation animationWithKeyPath:keyPath];
    animationScale.duration = 0.1;
    animationScale.repeatCount = 1;
    animationScale.fromValue = @(0.0);
    animationScale.toValue = @(1.0);
    animationScale.removedOnCompletion = NO;
    
    CGRect frame = self.optionsView.frame;
    view.layer.anchorPoint = CGPointMake(0.7, 0);
    view.frame = frame;
    [view.layer addAnimation:animationScale forKey:keyPath];
}

iOS 放大缩小动画嵌套实现 (注意:这个是以视图中心为起点放大的)

self.yuntaiCameraView.collectBtn.transform = CGAffineTransformMakeScale(2.5, 2.5);

    [UIView animateWithDuration:2

                     animations:^{

                         self.yuntaiCameraView.collectBtn.transform = CGAffineTransformMakeScale(1.2, 1.2);

                         [self.yuntaiCameraView.collectBtn setHighlighted:YES];

                     }completion:^(BOOL finish){

                         [UIView animateWithDuration:2

                                          animations:^{

                                              self.yuntaiCameraView.collectBtn.transform = CGAffineTransformMakeScale(0.8, 0.8);

                                          }completion:^(BOOL finish){

                                              [UIView animateWithDuration:3

                                                               animations:^{

                                                                   self.yuntaiCameraView.collectBtn.transform = CGAffineTransformMakeScale(1, 1);

                                                               }completion:^(BOOL finish){

                                                                   [self.yuntaiCameraView.collectBtn setHighlighted:NO];

                                                               }];

                                          }];

                     }];

猜你喜欢

转载自blog.csdn.net/allanGold/article/details/84143661