"iOS Development Series" Physical simulation animation uidynamic (1)

Source: Internet
Author: User

iOS Development Extension Chapter-uidynamic (Brief introduction) "One" brief introduction 1. What is Uidynamicuidynamic is a new technology introduced from iOS 7 that belongs to the Uikit framework can be considered a physical engine, Simulation and simulation of real-life physical phenomena such as: gravity, elastic collision and other phenomena 2. The value of the physics engine is widely used in game development, the classic success story is "Angry Birds" allows developers to move away from the physics formula, the implementation of cool physical simulation results improve the game development efficiency, Generate more great fun physics simulation Games 3. The well-known 2D physics engine box2dchipmunk "two" steps to use uidynamic to achieve physical simulation effects, The approximate steps are as follows (1) Create a physical emulator (by the way set the simulation scope) (2) Create the corresponding physical simulation behavior (by adding physical simulation elements) (3) to add the physical simulation behavior to the physical emulator?  Start the simulation of the "three" related notes 1. Three concepts (1) who wants to perform physical simulations? What is the physical simulation effect of the physical simulation element (Dynamic Item) (2)?  What kind of animated effect? Physical simulation behavior (dynamic Behavior) (3) enables physical simulation elements to perform specific physical simulation behavior of the physical emulator (dynamic Animator) 2. Physical Simulation Elements Note: Not all objects can do physical simulation elements not all objects can be physically emulated physical simulation element features: Any object that complies with the Uidynamicitem protocol UIView has complied with the Uidynamicitem protocol by default, so any UI control can do    Physical simulation The Uicollectionviewlayoutattributes class also complies with Uidynamicitem Protocol 3. Physical simulation Behavior (1) Uidynamic provides the following physical simulation behavior Uigravitybehavior: Gravity behavior Uicollisionbehavior: Collision behavior Uisnapbehavior: Snapping behavior uipushbehavior: Driving behavior Uiattachmentbehavior: attached Behavior Uidynamicitembehavior: Dynamic Elemental Behavior (2) Physical simulation behavior Note all of the above physical simulation behaviors are inherited from Uidynamicbehavior all Uidynamicbehavior can be combined using a variety of Behavior, you can achieve some of the more complex effects 4. Physical Emulator (1) The physical emulator can be used to let physical simulation elements perform physical simulation behavior it is UIdynamicanimator object of type (2) Uidynamicanimator initialization-(instancetype) Initwithreferenceview: (UIView *) view;    View parameter: is a reference view that represents the scope of the physical simulation 5. Description of the physical emulator (1) Common methods of Uidynamicanimator-(void) Addbehavior: (Uidynamicbehavior *) behavior;  Add 1 physical emulation behaviors-(void) Removebehavior: (Uidynamicbehavior *) behavior;    Removal of 1 physical simulation behaviors-(void) removeallbehaviors;  Remove all physical emulation behaviors previously added (2) Uidynamicanimator Common Properties @property (nonatomic, readonly) uiview* Referenceview; Refer to view @property (nonatomic, readonly, copy) nsarray* behaviors;//All physical emulation behavior @property added to the physical emulator (nonatomic, ReadOnly, get ter = isrunning) BOOL running;//is in the physical emulation @property (nonatomic, assign) ID <UIDynamicAnimatorDelegate> delegate;/ /proxy object (a simulation process that listens to a physical emulator, such as Start and end)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"iOS Development Series" Physical simulation animation uidynamic (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.