国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

ios按鈕點擊后翻轉(zhuǎn)效果

2019-11-14 20:19:31
字體:
供稿:網(wǎng)友

代碼是網(wǎng)上找到的,不過找到的時候直接復(fù)制下來不能用,稍微整理下,為和我一樣水平的菜鳥觀摩一下下。

 

(1)引入“QuartzCore.framework”庫,頭部引用。

 

 

C代碼  收藏代碼
  1. #include<QuartzCore/CoreAnimation.h>  

 

(2)直接上代碼,你懂的。

 

 

C代碼  收藏代碼
  1. -(IBAction)buttonP:(id)sender{  
  2.     [self buttonAnimation:sender];  
  3. }  
  4.   
  5. - (CAAnimation *) animationRotate {  
  6.     CATransform3D rotationTransform  = CATransform3DMakeRotation( M_PI/2 , 0 , 1 , 0 );  
  7.     CABasicAnimation* animation;  
  8.     animation = [CABasicAnimation animationWithKeyPath:@"transform"];  
  9.     animation.toValue = [NSValue valueWithCATransform3D:rotationTransform];  
  10.     animation.duration = 3;  
  11.     animation.autoreverses = YES;  
  12.     animation.cumulative = YES;  
  13.     animation.repeatCount = 1;  
  14.     animation.beginTime = 0.1;  
  15.     animation.delegate = self;  
  16.     return animation;  
  17. }  
  18.   
  19. - (void)buttonAnimation:(id) sender{  
  20.     UIButton *theButton = sender;  
  21.     CAAnimation *myAnimationRotate = [self animationRotate];  
  22.     CAAnimationGroup* m_pGroupAnimation;  
  23.     m_pGroupAnimation = [CAAnimationGroup animation];  
  24.     m_pGroupAnimation.delegate = self;  
  25.     m_pGroupAnimation.removedOnCompletion = NO;  
  26.     m_pGroupAnimation.duration = 10;  
  27.     m_pGroupAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaSEOut];     
  28.     m_pGroupAnimation.repeatCount = 1;  
  29.     m_pGroupAnimation.fillMode = kCAFillModeForwards;  
  30.     m_pGroupAnimation.animations = [NSArray arrayWithObjects:myAnimationRotate, nil];  
  31.     [theButton.layer addAnimation:m_pGroupAnimation forKey:@"animationRotate"];  
  32. }  
  33.     
  34. - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{  
  35.     //todo  
  36. }  

 

PS:

 

CATransform3DMakeRotation( M_PI/2 , 0 , 1 , 0 );第一個參數(shù)是旋轉(zhuǎn)的角度,有一點需要著名,就是對象回按照你設(shè)定的角度的最短距離去旋轉(zhuǎn),后面三個參數(shù)分別是xyz(-1~1之間的值)代表的一個向量值。順時針或者逆時針旋轉(zhuǎn)尚未搞定具體是什么參數(shù)來控制的,有知道的朋友提醒下,謝謝!

 

 

 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 承德市| 开化县| 呼图壁县| 临海市| 即墨市| 慈利县| 英山县| 如皋市| 巴中市| 沙河市| 桃源县| 大英县| 中西区| 明星| 元氏县| 巨鹿县| 宁夏| 蒙自县| 横峰县| 辛集市| 美姑县| 安阳县| 穆棱市| 贵南县| 临颍县| 宜宾市| 乌鲁木齐县| 彩票| 郸城县| 东至县| 上虞市| 龙陵县| 黄陵县| 麻江县| 蓝田县| 自治县| 岱山县| 通许县| 奈曼旗| 额尔古纳市| 平湖市|