2010-08-13 153 views
0

這段代碼爲什麼不做任何事情?UIView動畫

[UIView beginAnimations:@"View Flip" context:nil]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
[UIView setAnimationTransition:UIViewAnimationCurveEaseIn forView:self.view cache:YES]; 

[self.view removeFromSuperview]; 

[UIView commitAnimations]; 

此外,我在哪裏可以看到beginAnimations可能參數的所有列表:?

回答

6

,則應該設置在包含變化的視圖,e.g動畫過渡..

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
         forView:self.view.superview cache:YES]; 

此外,過渡應該是UIViewAnimationTransition類型的一個常數。

+beginAnimations:context:方法可以將任何字符串作爲其第一個參數,並將任何指針作爲其第二個參數。

+0

賦予任意字符串beginAnimations的目的是什麼? – 2010-08-14 23:15:37

+0

@awake:如果你有一個'+ setAnimationWillStartSelector:'給出一個動畫標識符,等等。 – kennytm 2010-08-15 06:05:57

+0

我只需要添加超級​​視圖並修復它。 – 2010-08-15 08:52:19

0

使用QuartzCore.framework有了這些動畫。

-(void)viewSlideInFromRightToLeft:(UIView *)views 
{ 
    CATransition *transition = nil; 
    transition = [CATransition animation]; 
    transition.duration = 0.5;//kAnimationDuration 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    transition.type = kCATransitionPush; 
    transition.subtype =kCATransitionFromRight; 
    transition.delegate = self; 
    [views.layer addAnimation:transition forKey:nil]; 
} 

-(void)viewSlideInFromLeftToRight:(UIView *)views 
{ 
    CATransition *transition = nil; 
    transition = [CATransition animation]; 
    transition.duration = 0.5;//kAnimationDuration 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    transition.type = kCATransitionPush; 
    transition.subtype =kCATransitionFromLeft; 
    transition.delegate = self; 
    [views.layer addAnimation:transition forKey:nil]; 
} 

-(void)viewSlideInFromTopToBottom:(UIView *)views 
{ 
    CATransition *transition = nil; 
    transition = [CATransition animation]; 
    transition.duration = 0.5;//kAnimationDuration 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    transition.type = kCATransitionPush; 
    transition.subtype =kCATransitionFromBottom ; 
    transition.delegate = self; 
    [views.layer addAnimation:transition forKey:nil]; 
} 

-(void)viewSlideInFromBottomToTop:(UIView *)views 
{ 
    CATransition *transition = nil; 
    transition = [CATransition animation]; 
    transition.duration = 0.5;//kAnimationDuration 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    transition.type = kCATransitionPush; 
    transition.subtype =kCATransitionFromTop ; 
    transition.delegate = self; 
    [views.layer addAnimation:transition forKey:nil]; 
} 

對於將animationType您可以使用以下選項: kCATransitionMoveInkCATransitionPushkCATransitionRevealkCATransitionFade

對於AnimationSubType您可以使用以下選項: kCATransitionFromLeftkCATransitionFromRightkCATransitionFromTopkCATransitionFromBottom