首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

ios旋钮点击后翻转效果

2012-07-26 
ios按钮点击后翻转效果上图先,图上是一个按钮,点击后旋转,代码是网上找到的,不过找到的时候直接复制下来不

ios按钮点击后翻转效果

上图先,图上是一个按钮,点击后旋转,代码是网上找到的,不过找到的时候直接复制下来不能用,稍微整理下,为和我一样水平的菜鸟观摩一下下。

?

(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:

?

ios旋钮点击后翻转效果
?
ios旋钮点击后翻转效果

?

热点排行