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.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動畫

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM