简体   繁体   中英

How do I make animations in an iPad app?

I'm developing an application for iPad.

I want to make nice animations so that I can beautify my application. For example, there are 4 main buttons/images in a view. When tapping on one of them, a few more buttons/images will branch out.

It's like the 'parent button' will branch out to few 'child buttons'.

How are these kind of animations done? Are there any good references or code snippets to refer to?

Thanks.

A good stating point would be the Core Animation demo's here:

https://github.com/neror/CA360

Run them in the iOS Simulator and checkout the code that creates the magic.

UIView animations would also be suitable for your example, and are a little easier to implement. There is a nice tutorial here:

http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial

Search on the term "Core Animation iOS" on your favorite search engine. You'll find information from Apple's Developer Central site, particularly the Core Animation Guide and Cookbook .

There are actually 2 main methods.

One is to use Core Animation, if it contains your desired path and animation.

The other is to use an animation game loop, where the app periodically calls a routine to redraw the view every frame time. An NSTimer or CADisplayLink can periodically (say at 24 or 30 or 60 Hz) call a routine doing a setNeedsDisplay, which then causes the view's drawRect to be called, etc. The some other periodic code can change some state (moving some XY button positions, etc.) during or between each frame to provide the appearance of movement or other animation effect, when the view is redrawn. Or OpenGL can be used to redraw some animated 3D world as things move. You can even have each frame change in response to user input. This is the most flexible way to animate, and allows you to customize animations in ways that are impossible for Core Animation, but it uses more power and can be so CPU intensive as to be a lot slower than Core Animation as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM