ios开发 按钮点击后翻转效果
2013-06-07 09:29
369 查看
(1)引入“QuartzCore.framework”库,头部引用。
#include<QuartzCore/QuartzCore.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之间的值)代表的一个向量值。顺时针或者逆时针旋转尚未搞定具体是什么参数来控制的,有知道的朋友提醒下,谢谢!
相关文章推荐
- iOS开发之--去除按钮的点击效果
- iOS开发:多个按钮点击滑动效果
- ios按钮点击后翻转效果
- ios按钮点击后翻转效果
- IOS 按钮自定义点击效果(UI Color 转换成UI Image)
- ios开发-新浪微博12-(标题按钮的箭头上下翻转)
- iOS去掉按钮的点击效果
- iOS开发禁用多个按钮同时点击导致误触
- IOS 按钮点击发光效果
- iOS点击文字按钮变转圈加载效果
- android仿IOS按钮点击效果,一张图片实现
- IOS 点击按钮 光环 冲击波效果
- iOS 点击按钮没有效果解决办法
- iOS取消按钮点击时的动画效果
- iOS开发 之 WebView点击图片看大图效果
- iOS开发-截获html按钮点击事件,实现js调用native代码
- IOS开发UISearchBar失去第一响应者身份后,取消按钮不执行点击事件的问题
- ios开发学习--按钮(Button)效果源码分享
- iOS开发:在XIB中设置按钮不同点击状态下的不同图标显示
- iOS开发:点击系统的返回按钮,返回到指定的视图