【问题标题】:Scale a UIView with animation but without Transform缩放带有动画但不带变换的 UIView
【发布时间】:2015-10-27 14:23:48
【问题描述】:

我尝试将UIView 缩放为圆形,以便在单击时将其放大一倍。

我的最终目标是重现苹果音乐的行为: - 当你点击一个圆圈时,它会增长并推动其他圆圈。

我正在尝试使用UIKit 动态来实现这一点,但第一个问题是没有CATransform 的比例动画(它不适用于碰撞)失败。

动画结束时,即使宽高为100, 最终的形状是一个矩形...

这是我的代码

func ballTapped(sender:UITapGestureRecognizer) {
        if sender.state == .Ended {
            collision.removeItem(sender.view!)
            let item = sender.view!
            var theFrame = item.frame
            theFrame.size.height = 100
            theFrame.size.width = 100
            UIView.animateWithDuration(0.5, animations: { () -> Void in
                    item.frame = theFrame
                }, completion: { (Bool) -> Void in
                    self.collision.addItem(sender.view!)
                }
            )
        }
    }

【问题讨论】:

    标签: ios objective-c animation uiview uikit


    【解决方案1】:
    [UIView animateWithDuration:0.5
                         animations:^{
    
                             [UIView animateWithDuration: 0.5 delay: 0.0 options:UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveEaseInOut animations:^{
    
                                 _iCarouselCarVW.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
                                 _iCarBackView.hidden = YES;
                                 NSLog(@"%f",self.view.frame.size.width);
                                 _iCarouselCenterConstant.constant = self.view.frame.size.width/2 + 50;
                                 [self.iCarouselCarVW setCurrentItemIndex:0];
                             } completion:^(BOOL finished)
                              {
    
    
                              }];
    
                             [self.view layoutIfNeeded]; // Called on parent view
                         }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-08
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 2011-03-31
      • 1970-01-01
      相关资源
      最近更新 更多