[IOS] UIDynamic, iosuidynamic
UIDynamic is a new technology introduced from iOS 7 and belongs to the UIKit framework. It can be considered as a physical engine,Simulate and simulate physical phenomena in real life: Such as gravity and elastic collision.
I. Concepts in UIDynamic
Three important classes:
UIDynamicItem Protocol(The object to execute the simulation animation)
To make a custom object eligible to participant ipate in UIKit Dynamics, adopt the UIDynamicItem protocol in the object's class.
Starting in iOS 7, the UIView and UICollectionViewLayoutAttributes classes implement this protocol.
UIDynamicAnimator Class(Equivalent to the Controller, simulator)
A dynamic animator provides physics-related capabilities and animations for its dynamic items, and provides the context for those animations. it does this by intermediating between the underlying iOS physics engine and dynamic items, via behavior objects you add to the animator.
UIDynamicBehavior Class(How to execute the animation)
A dynamic behavior confers a behavioral configuration on one or more dynamic items for their participates in two-dimen1_animation.
Ii. Use UIDynamic
TIPS:
1. Only objects that comply with the UIDynamicItem protocol can perform physical simulation. The UIView complies with the physical simulation.
2. Simulation behavior is generally inherited from UIDynamicBehavior. Each behavior can be independent or combined to make complex results.
UIDynamic provides the following physical simulation behaviors:
UIGravityBehavior: gravity Behavior
UICollisionBehavior: collision Behavior
UISnapBehavior: capture Behavior
Uipus?havior: Driving Behavior
UIAttachmentBehavior: attach behavior
UIDynamicItemBehavior: BEHAVIOR OF DYNAMIC ELEMENTS
A simple example of gravity fall:
# Import "XNViewController. h "@ interface XNViewController () // 1. instantiate a simulator @ property (nonatomic, strong) UIDynamicAnimator * animator; @ end @ implementation XNViewController-(UIDynamicAnimator *) animator {if (! _ Animator) {_ animator = [[UIDynamicAnimator alloc] initWithReferenceView: self. view];} return _ animator;}/** after the screen is clicked, the object begins to fall by gravity */-(void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {// 2. create physical simulation behavior // create a gravity simulation behavior (Items: Simulation element) UIGravityBehavior * gravity = [[UIGravityBehavior alloc] initWithItems: @ [self. box]; // create a collision simulation behavior UICollisionBehavior * collision = [[UICollisionBehavior alloc] initWithItems: @ [self. box, self. thing]; // specifies the collision range collision. translatesreferencebounds=boundary = YES; // 3. add the physical simulation behavior to the physical simulator [self. animator addBehavior: gravity]; [self. animator addBehavior: collision];} @ end
After clicking the screen, the collision effect is as follows:
Source code download: http://download.csdn.net/detail/xn4545945/7696865
There is a good example in the official documentation: Search for UIKit Dynamics Catalog to open it.
Here is also a good example: http://www.cocoachina.com/bbs/read.php? Tid = 168779
Refer to: Apple official documentation
Reprinted please indicate the source: http://blog.csdn.net/xn4545945
Versions available for IOS 30 and later
Currently, I know:
★IOS 3:
3.0 (7A341), 3.0.1 (7A400), 3.1 (7C144), 3.1.2 (7D11), 3.1.3 (7E18), 3.2 [iPad only], 3.2.1 [iPad only ], 3.2.2 [iPad only]
★IOS 4:
4.0 (8A293), 4.0.1 (8A306), 4.1 (8B117), 4.2.1 (8C148), 4.3 (8F190), 4.3.1 (8G4), 4.3.2 (8H7), 4.3.3 (8J2 ), 4.3.4 (8K2), 4.3.5 (8L1)
★IPhone 4.2.6, 4.2.7, 4.2.8, 4.2.9, and 4.2.10.
Beta ios versions
[Keep track tracks]
1 β ios <feat. Mika Kobayashi> Mika Kobayashi
2α
3Ω
4 Ready to Go <feat. David Whitaker> David Whitaker
5 friends <feat. mpi> mpi
6 VOiD
7g limit 19
8θ ε ο ι
9 close your eyes <feat. Michiyo Honda> Michiyo Honda
10 Β α σ ι λ ε υ ε
11π
12 Release My Soul <feat. Aimee Blackschleger> Why? When there are too many threads, there are too many threads.
13 K rOn Cores
14 Hill Of Sorrow <feat. mpi> mpi
15 Α π ο κ σ λ υ %%%%| |
16 Home ~ In this corner ~ <Feat. Leina> Leina
17 Genesi §
18 β-abymika Kobayashi <feat. Mika Kobayashi> Mika Kobayashi
19 R consumer. L <feat. Cyua> Cyua
OST
H please ttp: // 1 to 15.com/fi le/c2chinese bitj6w