+ All Categories
Home > Documents > Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please...

Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please...

Date post: 19-Jul-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
183
These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with UIKit Dynamics Olivier Gutknecht iOS Applications & Frameworks Engineer
Transcript
Page 1: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

These are confidential sessions—please refrain from streaming, blogging, or taking pictures

Session 206

Getting Started with UIKit Dynamics

Olivier GutknechtiOS Applications & Frameworks Engineer

Page 2: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What we will coverAgenda

Page 3: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What we will coverAgenda

• Core concepts

Page 4: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What we will coverAgenda

• Core concepts• Predefined behaviors

Page 5: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What we will coverAgenda

• Core concepts• Predefined behaviors• Best practices

Page 6: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

Page 7: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation

Page 8: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation• UIView animations

Page 9: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation• UIView animations• Motion effects

Page 10: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation• UIView animations• Motion effects• Gesture driven interactions

Page 11: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation• UIView animations• Motion effects• Gesture driven interactions• CADisplayLink

Page 12: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Animations and Interactions on iOS

• Core Animation• UIView animations• Motion effects• Gesture driven interactions• CADisplayLink• All of above

Page 13: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What Is UIKit Dynamics?

Page 14: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

What Is UIKit Dynamics?A composable, reusable, declarative,

real-world inspired animation, and interaction system

Page 15: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIKit Games

Page 16: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIKit Games

Page 17: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIKit Games

Page 18: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIKit Games

Page 19: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIKit Games

Page 20: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with
Page 21: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Sprite Kit

Introduction to Sprite Kit PresidioWednesday 11:30AM

Page 22: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Demo

Page 23: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How Complex Is This?Entire application: 400 lines of code

Page 24: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How Complex Is This?Entire application: 400 lines of code

80%

20%

DynamicsNon Dynamics

Page 25: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Overview

Page 26: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Why?

Page 27: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Real world inspired interactions

Why?

Page 28: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Real world inspired interactions• Combining predefined and interactive animations

Why?

Page 29: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Real world inspired interactions• Combining predefined and interactive animations

• Designed for UI

Why?

Page 30: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Real world inspired interactions• Combining predefined and interactive animations

• Designed for UI

Why?

Page 31: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Real world inspired interactions• Combining predefined and interactive animations

• Designed for UI

Why?

Page 32: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

Page 33: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

• High-level expression[myView setMass:0.42] ?

Page 34: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

• High-level expression[myView setMass:0.42] ?

Page 35: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

• High-level expression• Composition of…

Page 36: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

• High-level expression• Composition of…

■ Primitive behaviors

Page 37: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

How?

• High-level expression• Composition of…

■ Primitive behaviors

• Animation context

Page 38: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Architecture

UIDynamicAnimator

Page 39: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicBehaviorUIDynamicBehavior UIDynamicBehavior

Architecture

UIDynamicAnimator

Page 40: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicBehaviorUIDynamicBehavior UIDynamicBehavior

Architecture

UIDynamicAnimator

View View View

Page 41: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicBehaviorUIDynamicBehavior UIDynamicBehavior

Architecture

UIDynamicAnimator

View View View

Reference View

Page 42: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicBehaviorUIDynamicBehavior UIDynamicBehavior

Architecture

UIDynamicAnimator

View View View

Reference View

Page 43: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicBehaviorUIDynamicBehavior UIDynamicBehavior

Architecture

UIDynamicAnimator

View View View

Reference View

Page 44: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

Reference View

UIDynamicAnimator

Page 45: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

• Provide the overall context

Reference View

UIDynamicAnimator

Page 46: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

• Provide the overall context• Define the coordinate system

Reference View

UIDynamicAnimator

Page 47: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

• Provide the overall context• Define the coordinate system• Control the engine Reference View

UIDynamicAnimator

Page 48: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

• Provide the overall context• Define the coordinate system• Control the engine• Keep track of behaviors

Reference View

UIDynamicAnimator

Page 49: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicAnimator

• Provide the overall context• Define the coordinate system• Control the engine• Keep track of behaviors

Reference View

UIDynamicAnimator

animator = [[UIDynamicAnimator alloc] initWithReferenceView:referenceView];

[animator addBehavior:...];[animator addBehavior:...];

Page 50: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Reference View

UIDynamicBehavior

UIDynamicAnimator

Page 51: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Reference View

UIDynamicBehavior

UIDynamicBehavior

UIDynamicAnimator

Page 52: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 53: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 54: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative• Describe “influences” on views

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 55: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative• Describe “influences” on views• Added and removed at any time Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 56: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative• Describe “influences” on views• Added and removed at any time• Composable

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 57: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative• Describe “influences” on views• Added and removed at any time• Composable• Subclassable

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

Page 58: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

• Declarative• Describe “influences” on views• Added and removed at any time• Composable• Subclassable

Reference View

UIDynamicBehavior

View

UIDynamicBehavior

UIDynamicAnimator

myBehavior = [[MyBehavior alloc] initWith...];

[animator addBehavior:myBehavior];

Page 59: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Primitive Behaviors

Page 60: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Common Traits

• Configured with items to animate

Page 61: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Common Traits

• Configured with items to animate• Most primitive behaviors support adding and removing items

Page 62: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Common Traits

• Configured with items to animate• Most primitive behaviors support adding and removing items• Can be parametrized before adding to an animator

Page 63: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Common Traits

• Configured with items to animate• Most primitive behaviors support adding and removing items• Can be parametrized before adding to an animator• The influence stops when the behavior is removed

Page 64: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

Page 65: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity

Page 66: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity• Collision

Page 67: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity• Collision• Attachments

Page 68: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity• Collision• Attachments• Snap

Page 69: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity• Collision• Attachments• Snap• Forces

Page 70: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A rich set of composable classesPredefined Behaviors

• Gravity• Collision• Attachments• Snap• Forces• Item properties

Page 71: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

Page 72: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

Page 73: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector

Page 74: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

Page 75: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

• UIKit coordinate system

Page 76: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

• UIKit coordinate system■ (0,1) by default

Page 77: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

• UIKit coordinate system■ (0,1) by default

• Items can be added and removed at any time

Page 78: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIGravityBehavior

• A simple gravity vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

• UIKit coordinate system■ (0,1) by default

• Items can be added and removed at any time

g = [[UIGravityBehavior alloc] initWithItems:@[v]];

[animator addBehavior:g];

Page 79: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A Well-known Constant…Earth Gravity

Page 80: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A Well-known Constant…Earth Gravity9.80665 m/s²

Page 81: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Introducing…UIKit Gravity

Page 82: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Introducing…UIKit Gravity

1000 p/s²

Page 83: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

Page 84: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary

Page 85: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary

Page 86: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary• Or between views associated to the same behavior

Page 87: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary• Or between views associated to the same behavior

Page 88: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary• Or between views associated to the same behavior

• Or both, by default

Page 89: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Between a view and a boundary• Or between views associated to the same behavior

• Or both, by default

Page 90: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Collision mode@property (nonatomic, readwrite) UICollisionBehaviorMode collisionMode;

UICollisionBehaviorModeItemsUICollisionBehaviorModeBoundariesUICollisionBehaviorModeEverything

Page 91: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Collision mode@property (nonatomic, readwrite) UICollisionBehaviorMode collisionMode;

UICollisionBehaviorModeItemsUICollisionBehaviorModeBoundariesUICollisionBehaviorModeEverything

• Items can be added or removed at any time

Page 92: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• Collision mode@property (nonatomic, readwrite) UICollisionBehaviorMode collisionMode;

UICollisionBehaviorModeItemsUICollisionBehaviorModeBoundariesUICollisionBehaviorModeEverything

• Items can be added or removed at any time

Page 93: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• You can create multiple collision behaviors■ “red views collide with red views, green views with green views”

Page 94: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehavior

• You can create multiple collision behaviors■ “red views collide with red views, green views with green views”

• A word of warning: collisions have a CPU cost

Page 95: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

• Easy setup using the reference view@property (nonatomic, readwrite) BOOL translatesReferenceBoundsIntoBoundary;

Page 96: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

• Easy setup using the reference view@property (nonatomic, readwrite) BOOL translatesReferenceBoundsIntoBoundary;

• Or with insets-(void)setTranslatesReferenceBoundsIntoBoundaryWithInsets:(UIEdgeInsets)insets;

Page 97: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

Page 98: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

• Explicitly with segments - (void)addBoundaryWithIdentifier:(id)identifier fromPoint:(CGPoint)p1 toPoint:(CGPoint)p2;

Page 99: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

• Explicitly with segments - (void)addBoundaryWithIdentifier:(id)identifier fromPoint:(CGPoint)p1 toPoint:(CGPoint)p2;

• Or paths (approximated)- (void)addBoundaryWithIdentifier:(id)identifier forPath:(UIBezierPath*)p;

Page 100: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

BoundariesUICollisionBehavior

• Explicitly with segments - (void)addBoundaryWithIdentifier:(id)identifier fromPoint:(CGPoint)p1 toPoint:(CGPoint)p2;

• Or paths (approximated)- (void)addBoundaryWithIdentifier:(id)identifier forPath:(UIBezierPath*)p;

c = [[UICollisionBehavior alloc] initWithItems:@[view];

[c addBoundaryWithIdentifier:@”Wall1” fromPoint:p1 toPoint:p2];[c addBoundaryWithIdentifier:@”Wall2” fromPoint:p3 toPoint:p4];

Page 101: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehaviorDelegate

• Callback on begin and end of contact

Page 102: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehaviorDelegate

• Callback on begin and end of contact• Between views- collisionBehavior: beganContactForItem: withItem: atPoint:- collisionBehavior: endedContactForItem: withItem:

Page 103: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehaviorDelegate

• Callback on begin and end of contact• Between views- collisionBehavior: beganContactForItem: withItem: atPoint:- collisionBehavior: endedContactForItem: withItem:

• Or boundaries- collisionBehavior: beganContactForItem: withBoundaryIdentifier: atPoint:- collisionBehavior: endedContactForItem: withBoundaryIdentifier:

Page 104: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UICollisionBehaviorDelegate

• Callback on begin and end of contact• Between views- collisionBehavior: beganContactForItem: withItem: atPoint:- collisionBehavior: endedContactForItem: withItem:

• Or boundaries- collisionBehavior: beganContactForItem: withBoundaryIdentifier: atPoint:- collisionBehavior: endedContactForItem: withBoundaryIdentifier:

• The reference boundary identifier is always nil

Page 105: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

Page 106: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• Between a view and an anchor point

Page 107: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• Between a view and an anchor point a1 = [[UIAttachmentBehavior alloc] initWithItem:v1 attachedToAnchor:ap];

Page 108: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• Between a view and an anchor point a1 = [[UIAttachmentBehavior alloc] initWithItem:v1 attachedToAnchor:ap];

• Between two views

Page 109: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• Between a view and an anchor point a1 = [[UIAttachmentBehavior alloc] initWithItem:v1 attachedToAnchor:ap];

• Between two viewsa2 = [[UIAttachmentBehavior alloc] initWithItem:v1 attachedToItem:v2];

Page 110: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

Page 111: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• The view attachment point can be an offset from the centera1 = [[UIAttachmentBehavior alloc] initWithItem:v1 point:p1 attachedToAnchor:ap];a2 = [[UIAttachmentBehavior alloc] initWithItem:v1 point:p2 attachedToItem:v2];

Page 112: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

Page 113: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

Page 114: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• An attachment can act as a spring[a setFrequency:4.0];[a setDamping:0.5];

Page 115: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• An attachment can act as a spring[a setFrequency:4.0];[a setDamping:0.5];

• An anchor point can be modified later

Page 116: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• An attachment can act as a spring[a setFrequency:4.0];[a setDamping:0.5];

• An anchor point can be modified later• Only use length if to change the distance after setup

Page 117: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIAttachmentBehavior

• An attachment can act as a spring[a setFrequency:4.0];[a setDamping:0.5];

• An anchor point can be modified later• Only use length if to change the distance after setup

• Attachments are invisible!

Page 118: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Demo

Page 119: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

Page 120: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

• Snap a view in place

Page 121: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

• Snap a view in place

Page 122: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

• Snap a view in place• Ensure position and angle

Page 123: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

• Snap a view in place• Ensure position and angle• Damping is customizable

Page 124: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UISnapBehavior

• Snap a view in place• Ensure position and angle• Damping is customizable

s = [[UISnapBehavior alloc] initWithItem:v snapToPoint:p];[animator addBehavior:s];

Page 125: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

Page 126: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

Page 127: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Apply a force to a view (or views)p = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeContinuous];

Page 128: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Apply a force to a view (or views)p = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeContinuous];

• A simple force vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

@property (readwrite,nonatomic) CGFloat angle;@property (readwrite,nonatomic) CGFloat magnitude;

Page 129: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Apply a force to a view (or views)p = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeContinuous];

• A simple force vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

@property (readwrite,nonatomic) CGFloat angle;@property (readwrite,nonatomic) CGFloat magnitude;

• The target point can be customized[p setTargetPoint:x forItem:view];

Page 130: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Apply a force to a view (or views)p = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeContinuous];

• A simple force vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

@property (readwrite,nonatomic) CGFloat angle;@property (readwrite,nonatomic) CGFloat magnitude;

• The target point can be customized[p setTargetPoint:x forItem:view];

Page 131: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Apply a force to a view (or views)p = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeContinuous];

• A simple force vector@property (readwrite,nonatomic) CGFloat xComponent;@property (readwrite,nonatomic) CGFloat yComponent;

@property (readwrite,nonatomic) CGFloat angle;@property (readwrite,nonatomic) CGFloat magnitude;

• The target point can be customized[p setTargetPoint:x forItem:view];

Page 132: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with
Page 133: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A Well-known Unit…The Newton

Page 134: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

A Well-known Unit…The Newton

Accelerate 1kg at a rate of 1m/s²

Page 135: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Introducing…The UIKit Newton

Page 136: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Introducing…The UIKit Newton

Accelerate a (100,100) view to 100 p/s²

Page 137: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

Page 138: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Instantaneous modep2 = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeInstantaneous];

Page 139: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Instantaneous modep2 = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeInstantaneous];

• Velocity change is instantaneous

Page 140: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Instantaneous modep2 = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeInstantaneous];

• Velocity change is instantaneous

Page 141: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIPushBehavior

• Instantaneous modep2 = [[UIPushBehavior alloc] initWithItems:@[view] mode:UIPushBehaviorModeInstantaneous];

• Velocity change is instantaneous• Automatically disables itself after

■ Reenable with [p setActive:TRUE]

Page 142: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Demo

Page 143: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItemBehavior

Page 144: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItemBehavior

• Applied to one or many items

Page 145: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItemBehavior

• Applied to one or many items• Change item-level propertiesfrictionresistanceangularResistanceelasticitydensityallowsRotation

Page 146: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItemBehavior

• Applied to one or many items• Change item-level propertiesfrictionresistanceangularResistanceelasticitydensityallowsRotation

Page 147: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItemBehavior

• Applied to one or many items• Change item-level propertiesfrictionresistanceangularResistanceelasticitydensityallowsRotation

• Directly add angular or linear velocities■ i.e. map with a previous gesture

Page 148: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Applying Dynamics

Page 149: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Applying Dynamics

• Add and remove views to behaviors

Page 150: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Applying Dynamics

• Add and remove views to behaviors• Configure, add, and remove behaviors to an animator

Page 151: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Applying Dynamics

• Add and remove views to behaviors• Configure, add, and remove behaviors to an animator• There is no step 3

Page 152: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively• Not a physics-accurate tool

Page 153: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively• Not a physics-accurate tool

Page 154: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively• Not a physics-accurate tool

Page 155: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively• Not a physics-accurate tool

Page 156: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively

Page 157: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Don’t Expect the Impossible

• You can create setups which don’t have solutions

• Build your system iteratively• Not a physics-accurate tool

Page 158: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamic Items

Page 159: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

Page 160: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors

Page 161: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item

Page 162: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item

Page 163: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item

Page 164: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item

Page 165: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item

Page 166: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item• UIView implements it

Page 167: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem Protocol

• A protocol for items associated to predefined behaviors• Describe what UIKit needs to animate an item• UIView implements it• You can implement it

Page 168: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

UIDynamicItem

@protocol UIDynamicItem <NSObject>

@property (nonatomic, readwrite) CGPoint center;@property (nonatomic, readonly) CGRect bounds;@property (nonatomic, readwrite) CGAffineTransform transform;

@end

Page 169: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Collection View Layout Attributes

Page 170: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamics and UICollectionView

Page 171: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamics and UICollectionView

• UICollectionViewLayoutAttributes conforms to UIDynamicItem

Page 172: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamics and UICollectionView

• UICollectionViewLayoutAttributes conforms to UIDynamicItem• You can initialize an animator with a layoutanimator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:myLayout]

Page 173: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamics and UICollectionView

• UICollectionViewLayoutAttributes conforms to UIDynamicItem• You can initialize an animator with a layoutanimator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:myLayout]

• Just pass UICollectionViewLayoutAttributes to your behaviors

Page 174: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Dynamics and UICollectionView

• UICollectionViewLayoutAttributes conforms to UIDynamicItem• You can initialize an animator with a layoutanimator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:myLayout]

• Just pass UICollectionViewLayoutAttributes to your behaviors• UIKit will invalidate the layout as needed

Page 175: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Demo

Page 176: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Summary

Page 177: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Summary

• An interaction-oriented animation system

Page 178: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Summary

• An interaction-oriented animation system• Animate key elements

Page 179: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Summary

• An interaction-oriented animation system• Animate key elements• Focus on the user experience

Page 180: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Jake BehrensUI Frameworks [email protected]

DocumentationUIKit Framework Referencehttp://developer.apple.com/library/ios

Apple Developer Forumshttp://devforums.apple.com

More Information

Page 181: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Custom Transitions Using View Controllers Pacific HeightsThursday 11:30AM

Related Sessions

Advanced Techniques with UIKit Dynamics PresidioThursday 3:15PM

Designing Games with Sprite Kit MissionWednesday 2:00PM

Introduction to Sprite Kit PresidioWednesday 11:30AM

Page 182: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Labs

Scroll View, Collection View, and Table View on iOS Lab Frameworks Lab BWednesday 2:00PM

UIKit Dynamics Lab Frameworks Lab AWednesday 4:30PM

Cocoa Touch Animation Lab Frameworks Lab BThursday 2:00PM

Scroll View, Collection View, and Table View on iOS Lab Frameworks Lab BThursday 11:30AM

Cocoa Touch Lab Frameworks Lab BFriday 9:00AM

Cocoa Touch Lab Frameworks Lab AWednesday 9:00AM

Sprite Kit Lab Graphics and Games Lab BWednesday 3:15PM

Page 183: Getting Started with UIKit Dynamics · 2016-07-09 · These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 206 Getting Started with

Recommended