使用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您可以使用以下選項: kCATransitionMoveIn
, kCATransitionPush
, kCATransitionReveal
, kCATransitionFade
。
對於AnimationSubType您可以使用以下選項: kCATransitionFromLeft
, kCATransitionFromRight
, kCATransitionFromTop
, kCATransitionFromBottom
。
賦予任意字符串beginAnimations的目的是什麼? – 2010-08-14 23:15:37
@awake:如果你有一個'+ setAnimationWillStartSelector:'給出一個動畫標識符,等等。 – kennytm 2010-08-15 06:05:57
我只需要添加超級視圖並修復它。 – 2010-08-15 08:52:19