ios按钮点击后翻转效果
2014-07-04 17:17
344 查看
代码是网上找到的,不过找到的时候直接复制下来不能用,稍微整理下,为和我一样水平的菜鸟观摩一下下。
(1)引入“QuartzCore.framework”库,头部引用。
C代码
#include<QuartzCore/CoreAnimation.h>
(2)直接上代码,你懂的。
C代码
-(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之间的值)代表的一个向量值。顺时针或者逆时针旋转尚未搞定具体是什么参数来控制的,有知道的朋友提醒下,谢谢!
(1)引入“QuartzCore.framework”库,头部引用。
C代码
#include<QuartzCore/CoreAnimation.h>
(2)直接上代码,你懂的。
C代码
-(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开发 按钮点击后翻转效果
- android仿IOS按钮点击效果,一张图片实现
- iOS UIPanGestureRecognizer(拖动手势) 和 点击按钮 实现类似左抽屉的效果
- iOS中给自定义tabBar的按钮添加点击放大缩小的动画效果
- 制作翻转点击按钮效果方法
- iOS取消按钮点击时的动画效果
- iOS并排按钮点击联动效果封装
- iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的问题
- iOS去掉按钮的点击效果
- iOS取消按钮点击时的动画效果
- iOS 点击按钮没有效果解决办法
- android仿IOS按钮点击效果,一张图片实现
- ios 点击按钮,显示遮盖层的效果
- iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang
- iOS -点击按钮查看大图,再次点击还原效果(此处以UITableViewCell为父视图,其中加载多个图片为例)
- IOS 按钮点击发光效果
- iOS按钮点击效果消失
- iOS去掉按钮的点击效果
- IOS 按钮自定义点击效果(UI Color 转换成UI Image)