$30 off During Our Annual Pro Sale. View Details »

UIKit Dynamics

toco
December 11, 2013

UIKit Dynamics

A brief introduction to UIKit Dynamics.
Explains the base architecture and demonstrates the use of all framework provided behaviors.

Talk given at Alt Tech Talks Berlin (http://alt-tech-talks.com) – December 11th, 2013

The demo code is available on GitHub:
https://github.com/toco/Dynamic-ImageView
https://github.com/toco/Collisiontest

toco

December 11, 2013
Tweet

More Decks by toco

Other Decks in Programming

Transcript

  1. !
    UIKit Dynamics
    Tobias Conradi
    !1
    Alt Tech Talks Berlin
    December 11th, 2013

    View Slide

  2. What is
    UIKit Dynamics?
    !2

    View Slide

  3. http://blog.bignerdranch.com/3899-uikit-dynamics-and-ios-7-building-uikit-pong/
    http://www.teehanlax.com/blog/introduction-to-uikit-dynamics/
    ✗ ✔
    Not for UIKit-games!
    !3

    View Slide

  4. Motivation
    !4

    View Slide

  5. Tweetbot 3 for iOS 7
    !5
    http://tapbots.com/software/tweetbot/

    View Slide

  6. Tweetbot 3 for iOS 7
    !6
    http://tapbots.com/software/tweetbot/

    View Slide

  7. Architecture
    !7

    View Slide

  8. Architecture
    !8
    referenceView
    UIDynamicAnimator
    UIView!
    UIView!

    View Slide

  9. UIDynamicAnimator
    • Needs a reference view
    [[UIDynamicAnimator alloc]
    initWithReferenceView:referenceView];
    • Add behavior to animator
    [animator addBehavior:someBehavior]
    !9

    View Slide

  10. UIDynamicBehavior
    UIDynamicBehavior
    Architecture
    !10
    referenceView
    UIDynamicAnimator
    UIView!
    UIView!

    View Slide

  11. UIDynamicBehavior
    !11
    UIAttachmentBehavior UICollisionBehavior
    UIGravityBehavior
    +UIGravityBehavior
    https://developer.apple.com/library/ios/samplecode/DynamicsCatalog/

    View Slide

  12. UIDynamicBehavior
    !12
    UIDynamicItemBehavior UISnapBehavior
    UIPushBehavior
    +UIGravityBehavior
    +UICollisionBehavior

    View Slide

  13. UIDynamicBehavior
    • Add own behavior by using action-Block
    • Compose behaviors
    [behavior addChildBehavior:otherBehavior]
    • Subclassing makes the use compositions easier
    !13

    View Slide

  14. referenceView
    Architecture
    !14
    UIDynamicBehavior
    UIDynamicAnimator
    UIDynamicBehavior
    UIView!
    UIView!


    View Slide

  15. UIDynamicItem
    • Protocol
    • bounds (readonly)
    • center
    • transform
    • Implemented by:
    • UIView
    • UICollectionViewLayoutAttributes
    !15

    View Slide

  16. Implementation
    !16

    View Slide

  17. Attachment, Push, Snap &
    Collision
    !17
    https://github.com/toco/Dynamic-ImageView

    View Slide

  18. Demo
    !18

    View Slide

  19. Gravity, Collision &
    DynamicItemBehavior
    !19
    https://github.com/toco/Collisiontest

    View Slide

  20. More Information
    • WWDC 2013 Session 206:

    Getting Started with UIKit Dynamics
    • WWDC 2013 Session 221:

    Advanced Techniques with UIKit Dynamics
    • https://developer.apple.com/library/ios/samplecode/DynamicsCatalog/
    • http://www.teehanlax.com/blog/introduction-to-uikit-dynamics/
    • https://github.com/toco/Collisiontest
    • https://github.com/toco/Dynamic-ImageView
    • https://github.com/toursprung/TSMessages
    !20

    View Slide

  21. Contact
    Twitter: @toco91
    github.com/toco/
    xing.com/profiles/Tobias_Conradi3/
    !21

    View Slide