ios按钮点击后翻转效果
来源:互联网 发布:淘宝插件哪个好用 编辑:程序博客网 时间:2024/06/05 15:02
ios按钮点击后翻转效果
转入地址:http://gaobusi.iteye.com/blog/1461003
上图先,图上是一个按钮,点击后旋转,代码是网上找到的,不过找到的时候直接复制下来不能用,稍微整理下,为和我一样水平的菜鸟观摩一下下。
(1)引入“QuartzCore.framework”库,头部引用。
#include<QuartzCore/CoreAnimation.h>
(2)直接上代码,你懂的。
- -(IBAction)buttonP:(id)sender{
- [self buttonAnimation:sender];
- }
- - (CAAnimation *) animationRotate {
- CATransform3D rotationTransform = CATransform3DMakeRotation( M_PI/2 , 0 , 1 , 0 );
- CABasicAnimation* animation;
- animation = [CABasicAnimation animationWithKeyPath:@"transform"];
- animation.toValue = [NSValue valueWithCATransform3D:rotationTransform];
- animation.duration = 3;
- animation.autoreverses = YES;
- animation.cumulative = YES;
- animation.repeatCount = 1;
- animation.beginTime = 0.1;
- animation.delegate = self;
- return animation;
- }
- - (void)buttonAnimation:(id) sender{
- UIButton *theButton = sender;
- CAAnimation *myAnimationRotate = [self animationRotate];
- CAAnimationGroup* m_pGroupAnimation;
- m_pGroupAnimation = [CAAnimationGroup animation];
- m_pGroupAnimation.delegate = self;
- m_pGroupAnimation.removedOnCompletion = NO;
- m_pGroupAnimation.duration = 10;
- m_pGroupAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- m_pGroupAnimation.repeatCount = 1;
- m_pGroupAnimation.fillMode = kCAFillModeForwards;
- m_pGroupAnimation.animations = [NSArray arrayWithObjects:myAnimationRotate, nil];
- [theButton.layer addAnimation:m_pGroupAnimation forKey:@"animationRotate"];
- }
- - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
- //todo
- }
PS:
CATransform3DMakeRotation(M_PI/2 ,0 , 1 ,0 );第一个参数是旋转的角度,有一点需要著名,就是对象回按照你设定的角度的最短距离去旋转,后面三个参数分别是xyz(-1~1之间的值)代表的一个向量值。顺时针或者逆时针旋转尚未搞定具体是什么参数来控制的,有知道的朋友提醒下,谢谢!
0 0
- ios按钮点击后翻转效果
- iOS按钮点击效果消失
- IOS 按钮点击发光效果
- jquery 实现 点击按钮后倒计时效果
- iOS UITableViewCell点击效果,点击后消失
- iOS 禁用多按钮同时点击效果
- iOS去掉按钮的点击效果
- iOS去掉按钮的点击效果
- iOS 点击按钮没有效果解决办法
- iOS点击button放大后缩小效果
- iOS点击button放大后缩小效果
- onclick特效,按钮等点击后变化的效果
- jquery 实现验证码倒计时 点击按钮后倒计时效果
- 通过ValueAnimator 来实现按钮点击后倒计时的效果
- ios-----翻转效果 UIModalTransitionStyleFlipHorizontal
- 按钮点击(还原)效果
- 按钮点击效果
- 按钮点击效果不灵敏
- vim插件使用记录
- .htaccess HTTP访问跳转至HTTPS
- WEB前台的优化规则
- 在UIWebView中自定义显示选中文字的编辑菜单项
- 6-1. 简单计算器
- ios按钮点击后翻转效果
- 源码网站收藏
- 谷歌浏览器网页翻译失败解决方法
- ruby on rails错误undefined method `title' for nil:NilClass
- 6-2. 字符串字母大小写转换
- JAX-WS注解
- 自然数拆分
- CMFCRibbonButton使用HICON作为参数的构造函数BUG
- Failed to create the Java Virtual Machine