zoukankan      html  css  js  c++  java
  • 介绍一下开源项目FastAnimationWithPOP

    介绍一下开源项目FastAnimationWithPOP

    JUL 23RD, 2014

    这是一个非常easy的动画框架,基于Facebook的POP库。

    使用它你就能够在故事版中以0行代码的代价来加入动画了。

    Github上地址是 这里.

    你能够从这里下载DEMO查看效果.

    假设你认为不错,欢迎在到这里点个赞,方便让很多其它人注意到它

    Demo

    功能

    • 使用属性来加入一个动画到随意的View。

    • 在nib或者故事版唤醒时自己主动运行动画。

    • 也能够随时手动运行动画。
    • 控制动画的细节。
    • 给control绑定一些动画。比如按下松开等状态。
    • 轻松的扩展新的动画,仅仅须要实现FastAnimationProtocolControlFastAnimationProtocol 和 FastAnimationReverseProtocol这几个协议.

    环境要求

    iOS SDK: iOS 6.0+

    XCode版本号: 5.0+

    怎样安装

    最好的办法是使用CocoaPods:

    1. 加入这行到你的podfile文件 pod 'FastAnimation'

    2. 安装更新 pod install

    假设想要尝试最新的版本号。你能够加入这个pod 'FastAnimation', :head.

    使用指导

    1. 在故事板里使用

    你能够通过设置用户自己定义执行时属性(user defined runtime attributes)给View加入一个动画。

    StroyBoard1

    StroyBoard2

    以下是一些属性的含义:

    UIView的属性

    • animationType

      通过这个属性来指定动画的类型,能够是完整的类名,也能够省略FAAnimation前缀.

    • delay

      运行动画的延时。以秒为单位。

    • animationParams

      这个是各个动画的灵活參数。你能够从动画类的头文件里找到信息,比如以下:

    1
    2
    3
    4
    5
    
    #define kSpringBounciness   (@"animationParams.springBounciness")
    #define kSpringSpeed        (@"animationParams.springSpeed")
    #define kDynamicsTension    (@"animationParams.dynamicsTension")
    #define kDynamicsFriction   (@"animationParams.dynamicsFriction")
    #define kDynamicsMass       (@"animationParams.dynamicsMass")
    
    • startAnimationWhenAwakeFromNib

      定义是否须要在故事板唤醒的时候就运行动画,默认是YES

    UIControl的属性

    • bindingAnimationType

      通过这个属性来指定控件动画的类型。能够是完整的类名。也能够省略FAAnimation前缀.

    2. 代码写View的应用

    在代码写View中使用FastAnimation相同方便。

    你能够设置动画类型等属性。然后运行- (void)startFAAnimation就可以。就像这样:

    1
    2
    3
    4
    5
    6
    7
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    view.backgroundColor = [UIColor redColor];
    view.animationType = @"Shake";
    view.animationParams[@"velocity"] = @-7000;
    // You can also set params like this
    // [view setValue:@-7000 forKeyPath:kShakeVelocity];
    [view startFAAnimation];
    

    还有这些扩展的使用方法:

    1
    2
    3
    4
    5
    6
    
    // In UIView instance.
    - (void)startFAAnimation;
    - (void)reverseFAAnimation;
    // In UIControl instance.
    - (void)bindingFAAnimation;
    - (void)unbindingFAAnimation;
    

    3. 定义一个新的动画扩展

    轻松的扩展新的动画,仅仅须要实现FastAnimationProtocolControlFastAnimationProtocol 和 FastAnimationReverseProtocol这几个协议.

    就像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    
    // new_animation.h
    @interface FAAnimationNewAnimation : NSObject<FastAnimationProtocol,
    FastAnimationReverseProtocol> // Maybe only FastAnimationProtocol
    
    @end
    // new_animation.m
    @implementation FAAnimationBounceRight
    
    + (void)performAnimation:(UIView *)view
    {
        // some thing you like.
    }
    
    + (void)stopAnimation:(UIView *)view
    {
        // some thing you like.
    }
    
    + (void)reverseAnimation:(UIView *)view
    {
         // some thing you like.
    }
    
    + (void)stopReverse:(UIView *)view
    {
         // some thing you like.
    }
    @end
    

    4. 一些控制动画的操作

    • 停止动画:

    假设想要手动体制。使用以下的方法:

    1
    2
    
    - (void)stopFAAnimation;
    - (void)stopReverseFAAnimation;
    
    • 嵌套动画:

    使用例如以下方法处理嵌套:

    1
    2
    3
    4
    
    - (void)startFAAnimationNested;
    - (void)stopFAAnimationNested;
    - (void)reverseFAAnimationNested;
    - (void)stopReverseFAAnimationNested;
    

    眼下已经拥有的动画:

    • 反弹动画(4方向): BounceLeft,BounceRight,BounceUp,BounceDown
    • 放大动画(2方向):ZoomInX,ZoomInY
    • 颤动动画
    • 组动画
    • 放大动画
    • Button的放大效果绑定
    • 很多其它的动画等着大家的贡献哟。

    下一步要做的事

    • 把DEMO和库项目和到同一个Workspace里。

    • 制作很多其它更好看的DEMO。

    • 假如便捷的转场动画。眼下先设法支持iOS7+
    • 确保全部的功能都含有单元測试。

    • 很多其它更好的动画。
    • 把核心部分和效果部分分离,效果依照iOS5 6 7+来打成不同的包.
    • 支持Swift写扩展.

     Jul 23rd, 2014

  • 相关阅读:
    Owin
    C#不区分大小写的字符串替换(Replace)函数
    如何创建测试程序调试nginx数据结构
    一张脑图说清 Nginx 的主流程
    gdb常用命令记录
    nginx的configure流程
    c 编译器大全
    PHP 的 uniqid 函数产生的 id 真的是唯一的么?
    UUID那些事
    PHP 编码规范
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5390457.html
Copyright © 2011-2022 走看看