Iphone开发中的动画效果实现分类代码
2011-09-21 16:07
453 查看
Iphone开发中的动画效果实现分类代码
http://apps.hi.baidu.com/share/detail/30554489
- (void) first_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(resetView)];
CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));
CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);
CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);
[self.animatView setTransform:newTransform];
[UIView commitAnimations];
}
- (void) second_animations
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation setDuration:1];
[animation setRepeatCount:0];
[animation setAutoreverses:YES];//自动反向动画
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
[animation setToValue:[NSNumber numberWithFloat:0]];
[animation setDelegate:self];
[self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIView commitAnimations];
}
- (void) fourth_animations
{
CATransition *transition = [CATransition animation];
transition.duration = 1.0f; /* 间隔时间*/
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 动画的开始与结束的快慢*/
transition.type = @"pageCurl"; //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
transition.subtype = kCATransitionFromRight;
transition.removedOnCompletion = YES;
transition.fillMode = kCAFillModeBackwards;
transition.delegate = self;
[self.animatView.layer addAnimation:transition forKey:nil];
}
-(void) resetView
{
[self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#pragma mark Delegate Methods
- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#define degreesToRadian(x) (M_PI * (x) / 180.0)
有错误,请参考
http://hi.baidu.com/before%CB%AF%BE%F5/blog/item/b504f62dd10a7a291f3089f6.html
http://apps.hi.baidu.com/share/detail/30554489
- (void) first_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(resetView)];
CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));
CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);
CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);
[self.animatView setTransform:newTransform];
[UIView commitAnimations];
}
- (void) second_animations
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation setDuration:1];
[animation setRepeatCount:0];
[animation setAutoreverses:YES];//自动反向动画
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
[animation setToValue:[NSNumber numberWithFloat:0]];
[animation setDelegate:self];
[self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIView commitAnimations];
}
- (void) fourth_animations
{
CATransition *transition = [CATransition animation];
transition.duration = 1.0f; /* 间隔时间*/
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 动画的开始与结束的快慢*/
transition.type = @"pageCurl"; //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
transition.subtype = kCATransitionFromRight;
transition.removedOnCompletion = YES;
transition.fillMode = kCAFillModeBackwards;
transition.delegate = self;
[self.animatView.layer addAnimation:transition forKey:nil];
}
-(void) resetView
{
[self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#pragma mark Delegate Methods
- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#define degreesToRadian(x) (M_PI * (x) / 180.0)
有错误,请参考
http://hi.baidu.com/before%CB%AF%BE%F5/blog/item/b504f62dd10a7a291f3089f6.html
相关文章推荐
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- IPhone开发学习笔记:通过UIView实现动画效果
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 实现 iPhone 相机快门动画效果的代码例子
- 详解iPhone开发中各种动画实现效果
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- iPhone开发学习笔记通过UIView实现动画效果
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- android开发游记:通过xml配置快速实现点击热点效果和渐变动画(不用java代码)
- 使用NSTimer与iphone的简单动画,实现飘雪效果
- Asp.net 2.0 自定义控件开发[实现GridView多行表头固定表体滚动效果][示例代码下载]
- jquery的animate动画效果函数用JS代码是如何实现的
- jquery实现仿新浪微博带动画效果弹出层代码(可关闭、可拖动)
- iphone开发中的各种动画效果
- [导入]Asp.net 2.0 自定义控件开发[实现GridView多行表头固定表体滚动效果][示例代码下载]
- iphone游戏开发之cocos2d (七) 自定义精灵类,实现精灵动画CCAnimation
- IOS开发-UIView之动画效果的实现方法(合集)
- Animation动画效果(代码实现)
- Autolayout手写代码实现动画效果。
- 【Android UI设计与开发】10:滑动菜单栏(二)SlidingMenu 动画效果的实现