zoukankan      html  css  js  c++  java
  • 过场动画

    简单的动画:
    Core Animation是SDK四层结构中的第二层Media层中的重要组成部分,Quartz在这一层,而Core Animation位于Quartz之上,与Quartz的C语言函数库不同,它是基于Quartz的Objective-C封装。
    所有的视图UIView 都有一个layer属性,即是CALayer对象,CALayer是Core Animation的基础。所有的Core Animation 动画都是基于CALayer的。CALayer的属性有(anchorPoint,backgroundColor,opacity,position,transform)
    Core Animation 有两种动画类型:隐式动画 和显式动画
    1.隐式动画(不需要显式的创建CABasicAnimation或CAAnimation对象)只需要在“动画块”中修改CALayer的属性:
    (1)一个最简单示例
      [UIView beginAnimations:nil context:NULL];//1.标志“动画快"的开始
        CGAffineTransform moveTransform = CGAffineTransformMakeTranslation(200, 200);//2.创建一个放射变换对象。
        [self.baseView.layer setAffineTransform:moveTransform];//3.修改CALayer的transform属性
        self.baseView.layer.opacity = 1;//修改CALayer的opacity属性(动画效果是渐变)
        [UIView setAnimationDuration:1.0f];//4.设置动画持续时间,
        [UIView commitAnimations];//5.动画快结束标志,2)再给一个示例:这个例子是使用Block块,其中添加动画方法。
    [UIView animateWithDuration:0.5 animations:^{
           [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.window cache:NO];
            } completion:^(BOOL finished) {
          [_loadImgView removeFromSuperview];
      }];
    (3)再来一个,这个实现程序退出,并结合了两个的功能中使用到的方法
    #pragma mark - 退出程序动画操作
    -(void)exitApplication{
        [UIView beginAnimations:@"exitApplication" context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        UIWindow *win = [[UIApplication sharedApplication].windows objectAtIndex:0];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:win cache:NO];
        [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
        win.bounds = CGRectMake(0, 0, 0, 0);
        [UIView commitAnimations];
    }
    -(void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{
        if ([animationID compare:@"exitApplication"]==0) {
            exit(0);
        }
    }
    2.显式动画(需要显式地定义一个CABasicAnimation或CAAnimation对象来执行动画,其中有CABasicAnimation:CAPropertyAnimation,而CAPropertyAnimation:CAAnimation,CATransition:CAAnimation)
    CATransition* transition = [CATransition animation];
        transition.duration = 0.5;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade//动画类型设置
        transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom//动画开始点设置,动画开始方向设置。
        [self.navigationController.view.layer addAnimation:transition forKey:nil];
        [self.navigationController pushViewController:vc animated:NO];
    以上动画都是过场性的,也就是说不是连续的持久的动画,能够满足页面跳转,界面显示等常见的功能,这部分的参考文档可以查看链接:http://www.open-open.com/lib/view/open1372152939072.html
  • 相关阅读:
    hdu (欧拉函数+容斥原理) GCD
    UVA 11624 Fire!
    drf框架之跨域问题的解决与缓存问题
    drf框架之分页器的用法
    DRF框架之 用户角色权限与访问频率的权限设置
    DRF框架之认证组件用法(第四天)
    DRF框架之视图方法的几个封装好的模块介绍(第三天)
    DRF框架之 serializers 序列化组件
    DRF框架简介(第一天)
    BBS(第三天) 如何吧用户上传的图片文件保存到本地
  • 原文地址:https://www.cnblogs.com/longtaozi/p/3843829.html
Copyright © 2011-2022 走看看