BouncingAnimation 1.0.0

BouncingAnimation 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布上次发布2017年4月

dark19940411 维护。



  • dark19940411

这是一个使用 objective-c 编写的 iOS 平台上的弹跳动画。它只是 2D 动画,无法在 3D 变换中工作。
整个项目是一个带有动画组件(BouncingAnimation.h/.m)的示例项目。

安装

源代码

在此下载项目,并将 BouncingAnimation.h/.m 文件拖放到您的项目中。

将 BouncingAnimation 添加到您的项目中后,只需将其导入 BouncingAnimation.h 就可以使用它。

如何使用它?

使用公共工厂方法创建自定义弹跳动画。以下是一些例子

	CATransform3D fromt = CATransform3DIdentity;
	CATransform3D tot = CATransform3DMakeScale(2, 2, 1);
    
	BouncingAnimation *anim = [BouncingAnimation animationWithKeypath:@"transform"
                                                            fromValue:[NSValue valueWithCATransform3D:fromt]
                                                              toValue:[NSValue valueWithCATransform3D:tot]];

	[view.layer addAnimation:anim forKey:@""];                   

	CGFloat fromf = _view.layer.position.x;
	CGFloat tof = fromf - _view.bounds.size.width;
    
	BouncingAnimation *anim = [BouncingAnimation animationWithKeypath:@"position.x"
                                                            fromValue:[NSNumber numberWithFloat:fromf]
                                                              toValue:[NSNumber numberWithFloat:tof]];
                                                              
	[view.layer addAnimation:anim forKey:@""];   

	CGRect fromr = _view.layer.frame;
	CGRect tor = CGRectInset(fromr, 10, 10);
    
	BouncingAnimation *anim = [BouncingAnimation animationWithKeypath:@"bounds"
                                                            fromValue:[NSValue valueWithCGRect:fromr]
                                                              toValue:[NSValue valueWithCGRect:tor]];
                                                              
	[view.layer addAnimation:anim forKey:@""];   

有了这样的简单设置,您就可以自由地在视图中使用弹跳动画。

许可

此代码根据 MIT 许可协议的条款和条件分发。