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

来源:互联网 发布:linux 添加输入法 编辑:程序博客网 时间:2024/05/22 06:46

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

复制代码
 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.0f4                    options:UIViewAnimationOptionTransitionFlipFromLeft5                     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动画
复制代码
0 0
原创粉丝点击