2011-01-09 32 views
4

私は[window setFrame:frame animated:YES]を呼び出してウィンドウを拡大すると素晴らしい結果が得られますが、アニメーションが行われてステータスバーの後ろに表示されます。代わりにウィンドウをアニメーションにする方法はありますか?NSWindow setFrame:.. animated:YES]関数をアニメーション化する代わりに、代わりにアニメーションを使用できますか?

答えて

4

私はこれを行う簡単な方法を見つけることができませんでしたので、ウィンドウのサイズを変更して同時に移動させるアニメーション機能を作成し、アニメートする外観を与えました。

- (IBAction)startAnimations:(id)sender{ 

    NSViewAnimation *theAnim; 
    NSRect firstViewFrame; 
    NSRect newViewFrame; 
    NSMutableDictionary* firstViewDict; 

    { 
     firstViewDict = [NSMutableDictionary dictionaryWithCapacity:3]; 
     firstViewFrame = [window frame]; 
     [firstViewDict setObject:window forKey:NSViewAnimationTargetKey]; 

     [firstViewDict setObject:[NSValue valueWithRect:firstViewFrame] 
          forKey:NSViewAnimationStartFrameKey]; 

     newViewFrame = firstViewFrame; 

     newViewFrame.size.height += 100; 
     newViewFrame.origin.y -= 100; 

     [firstViewDict setObject:[NSValue valueWithRect:newViewFrame] 
          forKey:NSViewAnimationEndFrameKey]; 
    } 

    theAnim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray 
                   arrayWithObjects:firstViewDict, nil]]; 

    [theAnim setDuration:1.0]; 
    [theAnim startAnimation]; 

    [theAnim release]; 
} 
12

高さを増やすのと同じ距離だけy座標を小さくします。

CGFloat amountToIncreaseWidth = 100, amountToIncreaseHeight = 100; 
NSRect oldFrame = [window frame]; 
oldFrame.size.width += amountToIncreaseWidth; 
oldFrame.size.height += amountToIncreaseHeight; 
oldFrame.origin.y -= amountToIncreaseHeight; 
[window setFrame:oldFrame animated:YES]; 
+0

これは私がやったことです。理想的には、組み込みのアニメーション機能で何かしたいと思っていましたが、それを行う方法はありません。 –

+2

これは組み込みのアニメーションを使用します。 – ughoavgfhw

+0

これは正解です – lensovet

関連する問題