2012-04-15 22 views
0

我有一個視圖interface其中包含子視圖touchWheel。點擊interface上的最小化按鈕,我想執行轉換&將視圖發送到屏幕的右下角。事情是,我想「分離」touchWheel查看&將它與父視圖interface分開發送到角落,跟在後面(&實際上淡出)。單獨製作視圖及其子視圖動畫

當我嘗試這個我遇到一個問題。我的動畫最初工作正常& touchWheel發送到底角,根據需要。當touchWheel大約到達目的地的一半時,我生成interface,以便它遵循touchWheel

一旦interface開始動畫它似乎控制touchWheel & touchWheel更改當然。

看來interface仍然保留對touchWheel的控制權,因爲它是其父視圖。

- (void)hideInterfaceButtonClicked : (id) sender 
{ 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveGrey" object:self]; 

    //Remove Views & transform 
    [touchWheel removeViews]; 
    interfaceHidden = YES; 

     //Send Interface to corner 

[UIView animateWithDuration:1.25 
        delay:0.0 
       options:UIViewAnimationCurveEaseIn 
      animations:^{ 
       // Move to the right 

       CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(437,200); 
       // Scale 
       CGAffineTransform scale = CGAffineTransformMakeScale(0.135,0.135); 

       // Apply them to the view 
       self.transform = CGAffineTransformConcat(scale, translateInterface); 

       self.alpha = 0.0; 

      } completion:^(BOOL finished) { 
       NSLog(@"Animation Has Stopped"); 
       [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInterfaceViewNeeded" object:self]; //after MoveView finishes 


      }]; 



} 

製作touchWheel子視圖比interface其他東西造成這將事情進一步複雜化等問題。

任何想法如何解決這個問題?任何提示不勝感激:)

回答

2

你可以做到以下幾點:

  1. 移動touchWheelinterface的上海華盈,使用convertRect:toView:使touchWheel似乎有相同的窗口座標重新計算它的框架。
  2. 將兩個視圖動畫化爲其最終位置。
  3. 在動畫的完成塊中做與步驟1相反的操作:使touchWheel成爲interface的子視圖,再次重新計算其幀。

它看起來並不複雜,但有一個警告:您可能需要暫時禁用最大化按鈕(或任何適當的控件),以防止動畫期間的最大化操作。否則,這種方法會導致不可預知的結果。

+0

這是我最後提出的解決方案,以及:) – Octave1 2012-04-21 21:22:27

+0

@costique,請您回答類似的問題在這裏發佈.. https://stackoverflow.com/q/46053072/2534233 – user44776 2017-09-05 14:55:55