ing函数实现碰撞效果

ing函数实现碰撞效果

用Easing函数实现碰撞效果

用Easing函数实现碰撞效果-LMLPHP

用Easing函数实现碰撞效果-LMLPHP

工程中需要的源码请从这里下载:

https://github.com/YouXianMing/EasingAnimation

源码:

//
// ViewController.m
// EasingView
//
// Created by YouXianMing on 15/1/17.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import "ViewController.h"
#import "YXEasing.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 显示的view
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(, -, , )];
showView.backgroundColor = [UIColor clearColor];
showView.layer.borderColor = [UIColor redColor].CGColor;
showView.layer.borderWidth = .f;
showView.layer.cornerRadius = .f;
[self.view addSubview:showView]; // 关键帧动画
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; // 设置值
[animation setValues:[YXEasing calculateFrameFromPoint:showView.center
toPoint:CGPointMake(showView.center.x, showView.center.y + )
func:BounceEaseOut
frameCount:]]; // 设置持续时间
animation.duration = .f; // 执行动画效果
showView.center = CGPointMake(showView.center.x, showView.center.y + );
[showView.layer addAnimation:animation forKey:nil];
} @end
05-11 19:38