zoukankan      html  css  js  c++  java
  • CAMediaTimingFunction的使用

    CAMediaTimingFunction的使用

    CAMediaTimingFunction可以用在POP动画的自定义动画当中,算是非常实用的工具,当然,系统的动画也是可以使用的.

    效果:

    需要用到的工具:

    https://github.com/YouXianMing/Tween-o-Matic-CN

    测试用源码:

    //
    //  ViewController.m
    //  CoreAnimation
    //
    //  Created by XianMingYou on 15/4/13.
    //  Copyright (c) 2015年 XianMingYou. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
    
        // 初始化layer
        CALayer *layer        = [CALayer layer];
        layer.frame           = CGRectMake(50, 50, 200, 2);
        layer.backgroundColor = [UIColor blackColor].CGColor;
        
        
        // 终点位置
        CGPoint endPosition = CGPointMake(layer.position.x, layer.position.y + 200);
        
        
        // 动画
        CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
        animation.fromValue         = [NSValue valueWithCGPoint:layer.position];
        animation.toValue           = [NSValue valueWithCGPoint:endPosition];
        animation.timingFunction    = [CAMediaTimingFunction functionWithControlPoints:0.20 :0.03 :0.13 :1.00];
        layer.position              = endPosition;
        animation.duration          = 1.f;
        
        
        // 添加动画
        [layer addAnimation:animation forKey:nil];
        
    
        // 添加layer
        [self.view.layer addSublayer:layer];
    }
    
    @end

    需要注意的细节:

  • 相关阅读:
    puppet master/agent
    puppet单机模型
    Nginx MogileFS 配置
    mogilefs 安装与配置
    CMakeLists.txt
    下载安装MariaDB Galera 10.1
    BZOJ1295: [SCOI2009]最长距离
    BZOJ2375: 疯狂的涂色
    BZOJ1260: [CQOI2007]涂色paint
    BZOJ2789: [Poi2012]Letters
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4421492.html
Copyright © 2011-2022 走看看