• ios按钮点击后翻转效果


    代码是网上找到的,不过找到的时候直接复制下来不能用,稍微整理下,为和我一样水平的菜鸟观摩一下下。

    (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 );第一个参数是旋转的角度,有一点需要著名,就是对象回按照你设定的角度的最短距离去旋转,后面三个参数分别是xyz(-1~1之间的值)代表的一个向量值。顺时针或者逆时针旋转尚未搞定具体是什么参数来控制的,有知道的朋友提醒下,谢谢!

     

     

     

  • 相关阅读:
    Oracle学习笔记:使用replace、regexp_replace实现字符替换、姓名脱敏
    Oracle学习笔记:外连接(+)的用法
    Oracle学习笔记:with as子查询用法
    Oracle学习笔记:a inner join b与from a,b where a.x=b.x的差异
    oracle查看表,索引,视图,存储过程的定义
    oracle查看监听状态
    由sock引起的感想
    xargs
    oracle知识点小结1
    Oracle系统权限列表
  • 原文地址:https://www.cnblogs.com/lovewx/p/3824738.html
Copyright © 2020-2023  润新知