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

(1)引入“QuartzCore.framework”库,头部引用。

  1. #include<QuartzCore/CoreAnimation.h>

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

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

PS:

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

ios按钮点击后翻转效果的更多相关文章

  1. iOS中UIView翻转效果实现

    本文转载至  http://baishiyun.blog.163.com/blog/static/13057117920148228261747/ 新建一个view-based模板工程,在ViewCo ...

  2. CSS实现按钮点击后根据背景色加深效果-一颗优雅草bigniu

    具体代码如下 button{ position: relative; } button:active::before { display: block; content: ''; position: ...

  3. iOS UIcollectionView 实现卡牌翻转效果

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  4. iOS的view翻转动画实现--代码老,供参考

    新建一个view-based模板工程,在ViewController文件中添加下面的代码,即可实现翻转效果: - (void)viewDidLoad { [super viewDidLoad]; // ...

  5. Asp.net 按钮幕布遮盖效果实现方式

    Asp.net button按钮点击后想要实现幕布效果来等待服务器端执行完成,这种需求虽说看起来很简单,但真实做起来并不是那么简单,涉及了很多细节点,而对于深入理解asp.net button生命周期 ...

  6. 优秀前端工程师必备: (总结) 清除原生ios按钮样式

    写移动端的web开发时, 需要清除IOS本身的各种样式: 1.消除ios按钮原生样式, 给按钮加自定义样式: input[type="button"], input[type=&q ...

  7. Flutter实战视频-移动电商-60.购物车_全选按钮的交互效果制作

    60.购物车_全选按钮的交互效果制作 主要做全选和复选框的这两个功能 provide/cart.dart 业务逻辑写到provide里面 先持久化取出来字符串,把字符串编程list.循环list ca ...

  8. js简单 图片版时钟,带翻转效果

    js简单 图片版时钟,带翻转效果 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"& ...

  9. css3实现3D立体翻转效果

    1.在IE下无法显示翻转效果,火狐和谷歌可以 /*样式css*/ .nav-menu li { display: inline; } .nav-menu li a { color: #fff; dis ...

随机推荐

  1. ubuntu系统下安装gstreamer的ffmpeg支持

    当您在安装gstreamer到您的ubuntu系统中时,为了更好地进行流媒体开发,需要安装ffmpeg支持,但一般情况下,直接使用 sudo apt-get install gstreamer0.10 ...

  2. spf13-vim – The Ultimate Distribution for Vim Editor

    spf13-vim is a cross platform and highly customizable assortment of vim plugins and various resource ...

  3. asp.net MVC EF Where 过滤条件怎么写

    做.Net开发的肯定都知道.Net Sql语句有个SqlParameter 一般用来做过滤判断逻辑写,那么到了EF 了还有这样的写法嘛?答案肯定是有的了,这里我只是把最粗糙和简单的写法罗列一些,具体封 ...

  4. 数组去重算法,quickSort

    function removeRepeat(arr) { var arr2 = [] ,obj = {}; for (var i = 0; i<arr.length; i++) { var nu ...

  5. java之旅——JDK版本下载

    作为一名IT工作者,技术学无止境,最近开始学习java. 学习java就需要安装jdk,直接到官网上下载,总是找不到很好的版本,在资源中找到一个下载jdk的链接,想下载哪个版本都有. http://w ...

  6. 转:C# Autocad 关闭所有有色斑的图层

    /*关闭所有有色斑的图层 *  * 色斑图层比较多的情况下,一个一个弄比较麻烦,这个一次全关,再配合图层状态保存功能就非常容易相互切换了 *  * http://goat.cublog.cn * 作者 ...

  7. Fragment 总结

    本博客代码地址 : -- 单一 Fragment 示例 : https://github.com/han1202012/Octopus-Fragement.git -- 可复用的 Fragment 示 ...

  8. MVC 使用Jquery实现AJax

    View <script type="text/javascript"> function GetTime() { $.get("Home/GetTime&q ...

  9. 001.android初级篇之ToolBar

    官方的最新support library v7中提供了新的组件ToolBar,用来替代之前的ActionBar,实现更为弹性的设计在 material design 也对之做了名称的定义:App ba ...

  10. Swift - Property ''not initialized at super.init call

    Property ''not initialized at super.init call 这个错误应该挺常见的的,为什么在百度上没有找到呢,stack over flow找到了,也不能说是什么解决办 ...