Git Product home page Git Product logo

bouncinganimation's Introduction

BouncingAnimation

This is a bouncing animation on iOS platform written in objective-c.And it's merely a 2D animation, which is not working in 3D transform.
The whole project is a sample project with the animation components(BouncingAnimation.h/.m).

Install

Cocoapods

Add code below to your Podfile, and change 'Myapp' to your target name:

target 'MyApp' do
pod 'BouncingAnimation', '~> 1.0.0'
end

Then run pod install in your terminal.

Source code

Download the project here and drag the BouncingAnimation.h/.m files to your project.

After adding BouncingAnimation into your project, you can simply import BouncingAnimation.h to use it.

How to use it?

Use the public factory method to create custom bouncing animation. Here are some examples:

	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:@""];   

With these simply setup, you are free to go with a bouncing animation on your view.

License

This code is distributed under the terms and conditions of the MIT license.

bouncinganimation's People

Contributors

turtleeeeee avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.