码迷,mamicode.com
首页 > 其他好文 > 详细

CAMediaTimingFunction的使用

时间:2015-04-14 00:33:48      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

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

 

需要注意的细节:

技术分享

 

CAMediaTimingFunction的使用

标签:

原文地址:http://www.cnblogs.com/YouXianMing/p/4421492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!