isVisible = !isVisible;
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
// 要执行的动作代码部分 ---设计到界面变换的代码都写到这个位置。
[[self viewWithTag:IMAGE_VIEW_TAG] setAlpha:(float)isVisible];
[UIView commitAnimations]; // 提交要执行的动画
//---------------------------------------------------------------
// Start Animation Block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
// Animations -- 切换动画
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// Commit Animation Block
[UIView commitAnimations]; // 提交要执行的动画 //---------------------------------------------------------------
// 另一种节目切换动画,CATransition 类来实现
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType: kCATransitionPush];
[animation setSubtype: kCATransitionFromLeft];
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// 增加一个动画, 系统在界面切换的时候会自动调用此动画
[[[self superview] layer] addAnimation:animation forKey:@"transitionViewAnimation"];
|