2012-01-02 6 views
1

私はxcode 4で本当にシンプルなアプリケーションを開発しようとしています。これはユーティリティーアプリケーションで、メインビューが1つあり、 2つ以上の画像間で連続的にループする単純なアルファフェードを用いて背景の写真を表示する。xcodeで2つ以上の背景画像間のフェード(アルファ)を​​アニメ化する方法4

xcodeのユーザーマニュアルにいくつかのコードがありましたが、私はこれを変更しましたが、私はこれで新しく、既存のプロジェクトで以下のコードを動かす方法を尋ねています。私が見る二つの質問は最初、本当にあります作成するために、どのような店、何等:

// This method begins the first animation. 

- (IBAction)showHideView:(id)sender 

{ 

    [UIView beginAnimations:@"ShowHideView" context:nil]; 

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 

    [UIView setAnimationDuration:1.0]; 

    [UIView setAnimationDelegate:self]; 

    [UIView setAnimationDidStopSelector:@selector(showHideDidStop:finished:context:)]; 



    // Make the animatable changes. 

    secondImageView.alpha = 0.0; 



    // Commit the changes and perform the animation. 

    [UIView commitAnimations]; 

} 



// Called at the end of the preceding animation. 

- (void)showHideDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 

{ 

    [UIView beginAnimations:@"ShowHideView2" context:nil]; 

    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

    [UIView setAnimationDuration:1.0]; 

    [UIView setAnimationDelay:1.0]; 



    secondImageView.alpha = 1.0; 



    [UIView commitAnimations]; 

} 

答えて

0

置くことは正しい軌道上のアニメーションコードであり、アプリケーションに統合するために、第2の方法。

2番目の部分は、あなたがBig Nerd Ranchの本を見ている方が良いiPhone 101の基本的なものです。

最初の部分では、上記のアニメーションのやり方は古いスタイルであり、複雑なものです。

アニメーションブロックを使用するのが最も簡単な方法です。 http://pragmaticstudio.com/blog/2010/7/28/ios4-blocks-1

+0

感謝リー:ここ

は実際にあなたが要求しただけのよう画像のアルファをアニメーション化していること、その上で良い入門記事です。それはかなり役に立ちました。 – jhilgert00

関連する問題