UIView 动画效果的四种调用方式

本文通过具体的代码实例展示了如何在iOS应用中实现多种类型的UIView动画效果,包括淡入淡出、位移变化、翻页效果等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 - (void)fadeMe {
 2     [UIView animateWithDuration:1.0 animations:^{
 3         fadeMeView.alpha = 0.0f;    // 作用在fadeMeView视图
 4     }];
 5 }
 6 
 7 - (void)moveMe {
 8     [UIView animateWithDuration:0.5 animations:^{
 9         moveMeView.center = CGPointMake(moveMeView.center.x
                  , moveMeView.center.y - 200);  
// 作用在moveMeView视图
10 }];
11 }

 

 1     [UIView transitionWithView:noteView duration:0.6   // 在noteView视图上设置过渡效果
 2                        options:UIViewAnimationOptionTransitionCurlUp
 3                     animations:^{
 4                         NSString *currentText = noteView.text;
 5                         noteView.text = nextText;
 6                         self.nextText = currentText;
 7                     }
 8                     completion:^(BOOL finished){
 9                         
10                     }];

 

 1 //   前台页面
 2     UIView *frontView = [[UIView alloc] initWithFrame:self.view.bounds];
 3     frontView.backgroundColor = [UIColor colorWithRed:0.345 green:0.349 blue:0.365 alpha:1.000];
 4     UIImageView *caLogoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"caLogo.png"]];
 5     caLogoView.frame = CGRectMake(70, 80
 6                                   , caLogoView.bounds.size.width
 7                                   , caLogoView.bounds.size.height);
 8     [frontView addSubview:caLogoView];
 9     
10     // 后台页面
11     UIImage *backImage = [UIImage imageNamed:@"backView.png"];
12     UIImageView *backView = [[UIImageView alloc] initWithImage:backImage];
13     backView.userInteractionEnabled = YES;
14     
15     [self.view addSubview:backView];
16     [self.view addSubview:frontView];
1     [UIView transitionFromView:frontView    // 从原来视图转到新视图的动画效果设置
2                         toView:backView3                       duration:1.0f
4                    options:UIViewAnimationOptionTransitionFlipFromLeft
5                     completion:^{
6                     
7                     }];

 

 1     [UIView beginAnimations:@"View Flip" context:nil];
 2     
 3     [UIView setAnimationDuration:1.25];//动画持续时间
 4     [UIView setAnimationDelegate:self];//设置动画的回调函数,设置后可以使用回调方法
 5     [UIView  setAnimationCurve: UIViewAnimationCurveEaseInOut];//设置动画曲线,控制动画速度
 6     
 7     [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
 8                            forView:noteView
 9                              cache:YES];//设置动画方式,并指出动画发生的位置
10     
11     [UIView commitAnimations];//提交UIView动画

 

转载于:https://www.cnblogs.com/sell/archive/2013/02/09/2909522.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值