动画:UIKitAnimation 简单动画----渐变 、 移动 、翻页、来回翻转

转载请说明(谢谢)

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;

}

}];

}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值