2012-01-02 62 views
1

我試圖開發在Xcode 4一個非常簡單的應用程序這是一個實用的應用程序,其中一個主視圖2個或更多的背景圖像之間的動畫漸變(阿爾法),我想動畫系列在背景中用一個簡單的阿爾法淡入淡出照片,在兩個或更多圖像之間連續循環。如何在Xcode 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

實際上有兩個問題,我看,首先是在正確的軌道上的動畫代碼,第二如何將其集成到應用程序。

第二部分是隻是基本的iPhone 101的東西爲這你最好考慮看看大書呆子牧場書。

在第一部分,你在做上述動畫的方式是一個較舊的風格和複雜得多,它必須是。

最簡單的方法是使用動畫塊

這裏是一個不錯的介紹後,實際動畫圖像的阿爾法就像你要求: http://pragmaticstudio.com/blog/2010/7/28/ios4-blocks-1

+0

感謝李。這有所幫助。 – jhilgert00 2012-01-25 20:49:13