View之间切换的动态效果设置:
<wbr><wbr><wbr>SettingsController *settings = [[SettingsController alloc]initWithNibName:@"SettingsView" bundle:nil];<br><wbr><wbr><wbr>settings.modalTransitionStyle = UIModalTransitionStyleFl<wbr>ipHorizontal;<wbr>//水平翻转<br><wbr><wbr><wbr>[self presentModalViewControll<wbr>er:settings animated:YES];<br><wbr><wbr><wbr>[settings release];</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- (IBAction) activate:(UIView*)view
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nilcontext:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:CONST_animation_time];
[view setCenter:UpPointOfView(view)];
CABasicAnimation *scalingAnimation = (CABasicAnimation *)[view.layeranimationForKey:@"scaling"];
if (!scalingAnimation)
{
scalingAnimation = [CABasicAnimationanimationWithKeyPath:@"transform"];
scalingAnimation.repeatCount=1;
scalingAnimation.duration=CONST_animation_time;
scalingAnimation.autoreverses=NO;
scalingAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseOut];
scalingAnimation.fromValue=[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.0,1.0, 1.0)];
scalingAnimation.toValue=[NSValuevalueWithCATransform3D:CATransform3DMakeScale(CONST_enlarge_proportion,CONST_enlarge_proportion, 1.0)];
}
[view.layer addAnimation:scalingAnimationforKey:@"scaling"];
view.layer.transform =CATransform3DMakeScale(CONST_enlarge_proportion,CONST_enlarge_proportion, 1.0);
[UIView commitAnimations];
}
- (IBAction) deactivate:(UIView*)view
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nilcontext:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:CONST_animation_time];
[view setCenter:DownPointOfView(view)];
CABasicAnimation *scalingAnimation = (CABasicAnimation *)[view.layeranimationForKey:@"descaling"];
if (!scalingAnimation)
{
scalingAnimation = [CABasicAnimationanimationWithKeyPath:@"transform"];
scalingAnimation.repeatCount=1;
scalingAnimation.duration=CONST_animation_time;
scalingAnimation.autoreverses=NO;
scalingAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseOut];
scalingAnimation.fromValue=[NSValuevalueWithCATransform3D:CATransform3DMakeScale(CONST_enlarge_proportion,CONST_enlarge_proportion, 1.0)];
scalingAnimation.toValue=[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.0,1.0, 1.0)];
}
[view.layer addAnimation:scalingAnimationforKey:@"descaling"];
view.layer.transform =CATransform3DMakeScale(1.0,1.0, 1.0);
[UIView commitAnimations];
}
本文介绍了一种在iOS应用中实现视图切换时的动态效果的方法。通过使用UIKit和Core Animation,可以创建平滑的过渡动画,如水平翻转效果,并实现视图放大和缩小的动画。这些技术能够提升用户体验,使应用程序界面更加生动有趣。
1018

被折叠的 条评论
为什么被折叠?



