动画:UIKitAnimation 简单动画----渐变 、 移动 、翻页、来回翻转
2013-12-17 14:02
387 查看
转载请说明(谢谢)
http://blog.csdn.net/a21064346/article/details/7851695
点击打开链接
以下 一个系列的 动画效果 在 UIView.h文件中可以查找。但是比较炫丽的一些动画,就需要用到下一章节的coreAnimation。其中需要添加
QuartzCore
CoreGraphics
这两个framework
本人偷懒,就不搭建框架了。自己把方法复制到m文件里:)
//渐变 和 移动
- (UIGestureRecognizer *)createTapRecognizerWithSelector:(SEL)selector {
return[[[UITapGestureRecognizeralloc]initWithTarget:selfaction:selector]autorelease];
}
- (void)viewDidLoad {
[superviewDidLoad];
fadeMeView = [[UIViewalloc]initWithFrame:CGRectMake(55,40,210,160)];
fadeMeView.backgroundColor = [UIColorcolorWithRed:0.580green:0.706blue:0.796alpha:1.000];
[self.viewaddSubview:fadeMeView];
moveMeView = [[UIViewalloc]initWithFrame:CGRectMake(55,220,210,160)];
moveMeView.backgroundColor = [UIColorcolorWithRed:1.000green:0.400blue:0.400alpha:1.000];
[self.viewaddSubview:moveMeView];
[fadeMeViewaddGestureRecognizer:[selfcreateTapRecognizerWithSelector:@selector(fadeMe)]];
[moveMeViewaddGestureRecognizer:[selfcreateTapRecognizerWithSelector:@selector(moveMe)]];
}
- (void)fadeMe {
[UIViewanimateWithDuration:1.0animations:^{
fadeMeView.alpha = 0.0f;
}];
}
- (void)moveMe {
[UIViewanimateWithDuration:0.5animations:^{
moveMeView.center = CGPointMake(moveMeView.center.x,moveMeView.center.y -200);
}];
}
//翻书 翻页效果
- (void)CurlUp {
[UIViewtransitionWithView:noteViewduration:0.6
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
NSString *currentText =noteView.text;
noteView.text =nextText;
self.nextText = currentText;
}completion:^(BOOL finished){
}];
}
//同一容器中, view 左右来回翻转替换
- (void)viewDidLoad {
[superviewDidLoad];
self.title = [[selfclass]displayName];
// Set the background color for the window. The user will see the window's background color on the transition.
UIColor *backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageNamed:@"pattern.png"]];
[UIApplicationsharedApplication].keyWindow.backgroundColor =
backgroundColor;
frontView = [[UIViewalloc]initWithFrame:self.view.bounds];
frontView.backgroundColor =
[UIColorcolorWithRed:0.345green:0.349blue:0.365alpha:1.000];
UIImageView *caLogoView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"caLogo.png"]];
caLogoView.frame =CGRectMake(70,80, caLogoView.bounds.size.width,
caLogoView.bounds.size.height);
[frontViewaddSubview:caLogoView];
UIImage *backImage = [UIImageimageNamed:@"backView.png"];
backView = [[UIImageViewalloc]initWithImage:backImage];
backView.userInteractionEnabled = YES;
[self.viewaddSubview:backView];
[self.viewaddSubview:frontView];
displayingFrontView =YES;
UIGestureRecognizer *frontViewTapRecognizer = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(flipViews)];
UIGestureRecognizer *backViewTapRecognizer = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(flipViews)];
[frontViewaddGestureRecognizer:frontViewTapRecognizer];
[backViewaddGestureRecognizer:backViewTapRecognizer];
[frontViewTapRecognizerrelease];
[backViewTapRecognizerrelease];
}
- (void)flipViews {
[UIViewtransitionFromView:(displayingFrontView)
?frontView : backView
toView:(displayingFrontView) ? backView : frontView
duration:0.75
options:(displayingFrontView ?UIViewAnimationOptionTransitionFlipFromRight:UIViewAnimationOptionTransitionFlipFromLeft)
completion:^(BOOL finished) {
if (finished) {
displayingFrontView = !displayingFrontView;
}
}];
}
http://blog.csdn.net/a21064346/article/details/7851695
点击打开链接
以下 一个系列的 动画效果 在 UIView.h文件中可以查找。但是比较炫丽的一些动画,就需要用到下一章节的coreAnimation。其中需要添加
QuartzCore
CoreGraphics
这两个framework
本人偷懒,就不搭建框架了。自己把方法复制到m文件里:)
//渐变 和 移动
- (UIGestureRecognizer *)createTapRecognizerWithSelector:(SEL)selector {
return[[[UITapGestureRecognizeralloc]initWithTarget:selfaction:selector]autorelease];
}
- (void)viewDidLoad {
[superviewDidLoad];
fadeMeView = [[UIViewalloc]initWithFrame:CGRectMake(55,40,210,160)];
fadeMeView.backgroundColor = [UIColorcolorWithRed:0.580green:0.706blue:0.796alpha:1.000];
[self.viewaddSubview:fadeMeView];
moveMeView = [[UIViewalloc]initWithFrame:CGRectMake(55,220,210,160)];
moveMeView.backgroundColor = [UIColorcolorWithRed:1.000green:0.400blue:0.400alpha:1.000];
[self.viewaddSubview:moveMeView];
[fadeMeViewaddGestureRecognizer:[selfcreateTapRecognizerWithSelector:@selector(fadeMe)]];
[moveMeViewaddGestureRecognizer:[selfcreateTapRecognizerWithSelector:@selector(moveMe)]];
}
- (void)fadeMe {
[UIViewanimateWithDuration:1.0animations:^{
fadeMeView.alpha = 0.0f;
}];
}
- (void)moveMe {
[UIViewanimateWithDuration:0.5animations:^{
moveMeView.center = CGPointMake(moveMeView.center.x,moveMeView.center.y -200);
}];
}
//翻书 翻页效果
- (void)CurlUp {
[UIViewtransitionWithView:noteViewduration:0.6
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
NSString *currentText =noteView.text;
noteView.text =nextText;
self.nextText = currentText;
}completion:^(BOOL finished){
}];
}
//同一容器中, view 左右来回翻转替换
- (void)viewDidLoad {
[superviewDidLoad];
self.title = [[selfclass]displayName];
// Set the background color for the window. The user will see the window's background color on the transition.
UIColor *backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageNamed:@"pattern.png"]];
[UIApplicationsharedApplication].keyWindow.backgroundColor =
backgroundColor;
frontView = [[UIViewalloc]initWithFrame:self.view.bounds];
frontView.backgroundColor =
[UIColorcolorWithRed:0.345green:0.349blue:0.365alpha:1.000];
UIImageView *caLogoView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"caLogo.png"]];
caLogoView.frame =CGRectMake(70,80, caLogoView.bounds.size.width,
caLogoView.bounds.size.height);
[frontViewaddSubview:caLogoView];
UIImage *backImage = [UIImageimageNamed:@"backView.png"];
backView = [[UIImageViewalloc]initWithImage:backImage];
backView.userInteractionEnabled = YES;
[self.viewaddSubview:backView];
[self.viewaddSubview:frontView];
displayingFrontView =YES;
UIGestureRecognizer *frontViewTapRecognizer = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(flipViews)];
UIGestureRecognizer *backViewTapRecognizer = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(flipViews)];
[frontViewaddGestureRecognizer:frontViewTapRecognizer];
[backViewaddGestureRecognizer:backViewTapRecognizer];
[frontViewTapRecognizerrelease];
[backViewTapRecognizerrelease];
}
- (void)flipViews {
[UIViewtransitionFromView:(displayingFrontView)
?frontView : backView
toView:(displayingFrontView) ? backView : frontView
duration:0.75
options:(displayingFrontView ?UIViewAnimationOptionTransitionFlipFromRight:UIViewAnimationOptionTransitionFlipFromLeft)
completion:^(BOOL finished) {
if (finished) {
displayingFrontView = !displayingFrontView;
}
}];
}
相关文章推荐
- 动画:UIKitAnimation 简单动画学习 iOS (一) 渐变 、 移动 、翻页、来回翻转
- 动画:UIKitAnimation 简单动画学习 iOS (一) 渐变 、 移动 、翻页、来回翻转 ——转载
- 【Android开发小记--7】动画--简单的button移动和图片3D翻转
- Android基础-简单的动画实现 *补间动画 *透明度渐变 *旋转动画 *位移动画 *如果需要几个效果整合到一起,需要将所有效果全部放到set里
- 批量生成精灵,并实现拖拽精灵,和移动、翻转等简单动画
- UIKit 图片的移动、位移、旋转、缩放、翻转、翻页等特效的使用
- css3初体验之animation简单动画例子【来回滑动的小球】
- Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)
- 简单移动动画
- osg简单渐变动画物体的淡入淡出
- 简单JS动画实例 广告移动效果
- 安卓中为View添加动画效果(尺寸缩放、透明度渐变、旋转、移动)
- 移动web:翻页场景动画(结婚浪漫请柬)
- JS实现简单移动动画函数
- jq简单移动动画效果
- 史上最简单android动画之Tween Animation(渐变动画)
- 安卓属性动画与自定义控件实现圆球移动并实现颜色渐变
- 动画效果:位置移动、画面旋转、渐变透明度、渐变尺寸缩放
- 不用ViewPager一样做翻页,简单讲讲自定义3D动画
- 动画效果之简单的移动和移动渐变色