iOS UIkit Dynamic

865 views

Published on

Published in: Technology, Business
  • Be the first to comment

iOS UIkit Dynamic

  1. 1. UIKIT DYNAMICS 2014
  2. 2. INTRODUCTION • comprises four key elements • • The Reference View • Dynamic Items • • The Dynamic Animator Dynamic Behaviors Demo
  3. 3. THE DYNAMIC ANIMATOR • Responsible for coordinating the dynamic behaviors • Underlying physics engine to perform the animation • Represented by an instance of the UIDynamicAnimator class
  4. 4. EXAMPLE • @property (strong, nonatomic) UIDynamicAnimator *animator; • self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view]; ! ! • Class reference: https://developer.apple.com/library/ios/documentation/uikit/reference/ UIDynamicAnimator_Class/Reference/Reference.html
  5. 5. THE REFERENCE VIEW • Interaction are to take place • This is typically the parent superclass view or collection view of which the dynamic item views are children.
  6. 6. EXAMPLE • self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
  7. 7. DYNAMIC ITEMS • the view elements within the user interface that are to be animated • includes the UIView and UICollectionView classes and any subclasses there of (such as UIButton and UILabel)
  8. 8. DYNAMIC BEHAVIORS • configure the behavior which is to be applied to one or more dynamic items • predefined dynamic behavior classes • UIAttachmentBehavior • UICollisionBehavior • UIGravityBehavior • UIDynamicItemBehavior • UIPushBehavior • • The force can be specified as continuous or instantaneous UISnapBehavior
  9. 9. EXAMPLE Class *gravity = [[Class alloc]initWithItems:@[_view1, _view2]]; [self.animator addBehavior:gravity];
  10. 10. UICollisionBehavior Delegate <UICollisionBehaviorDelegate> [collision setCollisionDelegate:self]; • collisionBehavior:beganContactForItem:withBoundaryIdentifier:atPoint: • collisionBehavior:beganContactForItem:withItem:atPoint: • collisionBehavior:endedContactForItem:withBoundaryIdentifier: • collisionBehavior:endedContactForItem:withItem:
  11. 11. UIDynamicItemBehavior • AllowsRotation: Permitted to rotate during animation • AngularResistence: The higher the value, the faster the item will stop rotating • Density: The mass of the item • Friction: It slides against another item • Resistence: The item will come to a complete stop during animation. • Elasticity: Item will bounce
  12. 12. EXAMPLE UIDynamicItemBehavior *behavior = [[UIDynamicItemBehavior alloc] initWithItems:@[_view1, _view2]]; behavior.elasticity = 0.2; behavior.resistance = 0.5; [self.animator addBehavior:behavior];
  13. 13. UIDynamicBehavior • Combined to create a single custom behavior
  14. 14. EXAMPLE UIDynamicBehavior *customBehavior = [[UIDynamicBehavior alloc]init]; ! [customBehavior addChildBehavior:behavior]; [customBehavior addChildBehavior:attachment]; [customBehavior addChildBehavior:gravity]; [self.animator addBehavior:customBehavior];
  15. 15. UIkit dynamics architecture
  16. 16. I have no idea, what this guy was saying
  17. 17. Show me the demo
  18. 18. DEMO

×