2015-10-27 53 views
1

我嘗試使用圓形縮放UIView,使其在單擊時變成雙倍大小。使用動畫縮放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!) 
       } 
      ) 
     } 
    } 

回答

0
[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 
        }];