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

(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. 结合setTimeout和clearTimeout,实现“返回顶部”的功能

    结合setTimeout和clearTimeout,当页面停止滚动时,“返回顶部”按钮淡隐淡出.点击“返回顶部”页面以动画形式返回顶部.完美兼容ie6-11,firefox,chrome等. html ...

  2. 【NodeJS】---express配置ejs mongoose route等

    express创建项目 命令行下: express prj_name cd prj_name && npm install ejs html var ejs = require('ej ...

  3. 考上好大学,然后进入IT行业是穷人孩子晋级中产的唯一出路?

    今天看到一篇不错的文章,内容如下: 这个问题来自于我在知乎上参与的一个热贴讨论,作为一个10年的老码农,创业公司呆过,二.三流的互联网公司混过,BAT也遛了一趟,如今再次回归创业,经历算得上狗血了,看 ...

  4. Part 10 AngularJS sort rows by table header

    Here is what we want to do 1. The data should be sorted when the table column header is clicked 2. T ...

  5. Mac OS X中开启或关闭显示隐藏文件

    打开终端,输入:defaults write com.apple.finder AppleShowAllFiles -bool true 此命令显示隐藏文件defaults write com.app ...

  6. 【Unity3D】中的空引用 Null Reference Exception

    Null Reference Exception : Object reference not set to an instance of an object. 异常:空引用,对象的引用未设置到对象的 ...

  7. 理解C#系列 / 核心C# / 名称空间

    名称空间namespace 名称空间 名称空间用来逻辑分类,而不是物理上的,名称空间与程序集无关[程序集:经由编译器编译得到的文件],同一个程序集中可以有2不同的名称空间,也可以在不同的程序集中定义同 ...

  8. BeanDefinition的载入和解析

    1.在完成对代表BeanDefinition的Resource定位的分析后,下面来了解整个BeanDefinition信息的载入过程. 2.对IoC容器来说,这个载入过程,相当于把定义的BeanDef ...

  9. WCF之消息模式

    请求/响应:所有操作的默认行为,在WSDL中表现为Input/Output元素. One_Way. 在WSDL中只有Input,没有回应(Output),所以没有异常报告. 单向操作只会在发出调用的瞬 ...

  10. 兄台息怒,关于arguments,您的想法和大神是一样一样的----闲聊JS中的apply和call

    JavaScript提供了apply和call两种调用方式来确定函数体中this的指向,表现出来的特征就是:对象可以'借用'其他对象的方法.之前的几篇博客回顾了一些Web控件的一些开发方法,我们聊了如 ...