zoukankan      html  css  js  c++  java
  • iOS 转场动画核心内容

    CATransition——转场动画

    CATransition是CAAnimation的子类,用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果。iOS比Mac OS X的转场动画效果少一点。

    UINavigationController就是通过CATransition实现了将控制器的视图推入屏幕的动画效果。

    属性说明:

    属性说明
    type 动画过渡类型
    subtype 动画过度方向
    startProgress 动画起点(在整体动画的百分比)
    endProgress 动画终点(在整体动画的百分比)

    过渡效果设置


    type

    使用UIView动画函数实现转场动画——双视图

    + (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion;
    参数说明
    duration 动画持续时间
    option 动画类型
    animations 将改变视图属性的代码放在这个block中
    completion 动画结束后,会自动调用这个block

    CADisplayLink

    CADisplayLink是一种以屏幕刷新频率触发的时钟机制,每秒钟执行大约60次左右。

    CADisplayLink是一个计时器,可以使绘图代码与视图的刷新频率保持同步,而NSTimer无法确保计时器实际被触发的准确时间。

    使用方法:

    • 定义CADisplayLink并制定触发调用方法
    • 将显示链接添加到主运行循环队列
    // 定义
    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(rotationChange)];
    // 添加到主循环队列
    [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
    • 开始和暂停
    // 暂停
    link.paused = YES;
    // 开始
    link.paused = NO;
  • 相关阅读:
    系统生命周期
    系统分析师教程——目录
    企业信息系统——SCM
    企业信息系统——CRM
    .NET 解决方案 核心库整理
    .NET 人工智能相关资料整理
    Task
    正则表达式摘录
    记一次IOS对 JS的支持问题
    JavaScript回顾一下js的基础知识,以及学习一下在项目中了解到的新知识
  • 原文地址:https://www.cnblogs.com/yang-shuai/p/6490342.html
Copyright © 2011-2022 走看看