layout and animation techniques for watchkit...watchkit layout programming model you don’t write...

321
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC15 Layout and Animation Techniques For WatchKit Miguel Sanchez WatchKit Engineer Tom Witkin WatchKit Engineer App Frameworks Session 216

Upload: others

Post on 08-Oct-2020

29 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC15

Layout and Animation Techniques For WatchKit

Miguel Sanchez WatchKit EngineerTom Witkin WatchKit Engineer

App Frameworks

Session 216

Page 2: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Agenda

Page 3: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Agenda

Layout Fundamentals

Page 4: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Agenda

Layout FundamentalsUsing Groups

Page 5: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Agenda

Layout FundamentalsUsing GroupsExisting Animations in watchOS 1

Page 6: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Agenda

Layout FundamentalsUsing GroupsExisting Animations in watchOS 1New Animation API in watchOS 2

Page 7: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout Fundamentals

Page 8: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Model

Page 9: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Model

Same model as WatchKit in watchOS 1

Page 10: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Model

Same model as WatchKit in watchOS 1Different from UIKit and AppKit

Page 11: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Model

Same model as WatchKit in watchOS 1Different from UIKit and AppKitFlow-based layout

Page 12: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout ModelFlow-based layout

Page 13: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Page 14: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Page 15: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Image

Page 16: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Image

Page 17: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Image

Button

Page 18: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelFlow-based layout

Image

Button

Page 19: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelGroups are containers of elements

Group

Image

Button

Page 20: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

WatchKit Layout ModelGroups are containers of elements

Group

Image

Button

Page 21: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Interface Controller

10:09

Label

WatchKit Layout ModelGroups are containers of elements

Image

Button

Image

Page 22: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

Page 23: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

You don’t write object creation code

Page 24: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

You don’t write object creation codeFine tuned control of:

Page 25: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

You don’t write object creation codeFine tuned control of:• Layout hierarchy

Page 26: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

You don’t write object creation codeFine tuned control of:• Layout hierarchy• Alignment and sizing

Page 27: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WatchKit Layout Programming Model

You don’t write object creation codeFine tuned control of:• Layout hierarchy• Alignment and sizing• Animation

Page 28: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and Sizing

Page 29: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Page 30: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Page 31: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object

Page 32: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object• Horizontal and vertical

Page 33: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object• Horizontal and vertical• Left, center, or right

Page 34: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object• Horizontal and vertical• Left, center, or right

Size

Page 35: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object• Horizontal and vertical• Left, center, or right

Size• Width and height heuristic

Page 36: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment and SizeProperties on WKInterfaceObject

Alignment in containing object• Horizontal and vertical• Left, center, or right

Size• Width and height heuristic• Fixed, relative, or sized to fit

Page 37: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment APIWKInterfaceObject

func setHorizontalAlignment(WKInterfaceObjectHorizontalAlignment) func setVerticalAlignment(WKInterfaceObjectVerticalAlignment)

enum WKInterfaceObjectHorizontalAlignment { case Left case Center case Right }

enum WKInterfaceObjectVerticalAlignment { case Top case Center case Bottom }

Page 38: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment in Containing Element

myObj.setHorizontalAlignment(.Left) myObj.setVerticalAlignment(.Top)

Page 39: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

myObj.setHorizontalAlignment(.Center) myObj.setVerticalAlignment(.Center)

Alignment in Containing Element

Page 40: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

myObj.setHorizontalAlignment(.Right) myObj.setVerticalAlignment(.Bottom)

Alignment in Containing Element

Page 41: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sizing APIWKInterfaceObject

func setWidth(CGFloat) func setHeight(CGFloat)

func setRelativeWidth(CGFloat, adjustment : CGFloat) func setRelativeHeight(CGFloat, adjustment : CGFloat)

func sizeToFitWidth() func sizeToFitHeight()

Page 42: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sizing APIWKInterfaceObject

func setWidth(CGFloat) func setHeight(CGFloat)

func setRelativeWidth(CGFloat, adjustment : CGFloat) func setRelativeHeight(CGFloat, adjustment : CGFloat)

func sizeToFitWidth() func sizeToFitHeight()

Page 43: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Fixed Width and Height

myObj.setWidth(100) myObj.setHeight(100)

100

100

Page 44: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Fixed Width and Height

myObj.setWidth(100) myObj.setHeight(100)

Interpreting values of zero

watchOS 1 - default to storyboard

watchOS 2 - zero value

100

100

Page 45: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Relative to Container

Page 46: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Relative to Container

myObj.setRelativeWidth(0.75, 0)

Page 47: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

.25 .50 .75

Relative to Container

myObj.setRelativeWidth(0.75, 0)

Page 48: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Relative to Container

.25 .50 .75

.50

myObj.setRelativeHeight(0.50, 0)

myObj.setRelativeWidth(0.75, 0)

Page 49: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

.25 .50 .75

Adjustment Adds/Subtracts from Size

myObj.setRelativeWidth(0.75, 30)

myObj.setRelativeHeight(0.50, -30)

.50

Page 50: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

.25 .50 .75

Adjustment Adds/Subtracts from Size

myObj.setRelativeWidth(0.75, 30)

myObj.setRelativeHeight(0.50, -30)

.50

Page 51: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sized-to-Fit Content

myObj.sizeToFitWidth() myObj.sizeToFitHeight()

Page 52: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sized-to-Fit Content

myObj.sizeToFitWidth() myObj.sizeToFitHeight()

Page 53: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sized-to-Fit Content

myObj.sizeToFitWidth() myObj.sizeToFitHeight()

Sample Text

Page 54: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group ElementsFine tuning your layouts

Page 55: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Page 56: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Container without default content

Page 57: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Container without default content Tool for arranging elements

Page 58: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Container without default content Tool for arranging elements • Vertical or horizontal flow

Page 59: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Container without default content Tool for arranging elements • Vertical or horizontal flow• Nesting (including other groups)

Page 60: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfaceGroup

Container without default content Tool for arranging elements • Vertical or horizontal flow• Nesting (including other groups)• Fine control of alignment and sizing

Page 61: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 62: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 63: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 64: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 65: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 66: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Adding Horizontal Flow

Page 67: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Page 68: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Left Inset (10 points)

Page 69: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Bottom Inset(10 points)

Page 70: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Top Inset(10 points)

Page 71: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Right Inset (10 points)

Page 72: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Spacing (10 points)

Page 73: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Can Also Be Set at Top Level

Page 74: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Can Also Be Set at Top Level

Left Inset (10 points)

Page 75: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Can Also Be Set at Top LevelTop Inset (10 points)

Page 76: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Can Also Be Set at Top Level

Spacing (10 points)

Page 77: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Nesting for Complex Layouts

Page 78: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Nesting for Complex Layouts

Page 79: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Nesting for Complex Layouts

Page 80: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Nesting for Complex Layouts

Page 81: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layouts in WKRecipes

Page 82: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKRecipesRecipe Viewer

Page 83: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKRecipesIngredients

Page 84: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKRecipesServings

Page 85: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Let’s Explore Three Layouts

Page 86: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Rows

Page 87: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Rows

Image

Page 88: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Rows

Image Label

Page 89: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Table Row Controller

Image Label

Page 90: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Table Row Controller

Image LabelGroup with horizontal layout

Page 91: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Image Label

Page 92: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Image LabelLeft Inset(8 points)

Page 93: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Image Label

Bottom Inset(8 points)

Page 94: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Image Label

Top Inset(8 points)

Page 95: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Image LabelSpacing(8 points)

Page 96: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment

Image Label

Page 97: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment

Image LabelHorizontal: LeftVertical: Center

Horizontal: LeftVertical: Center

Page 98: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sizing

Image Label

Page 99: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sizing

Image LabelFixed SizeWidth 30Height 30

Page 100: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sizing

Image LabelFixed SizeWidth 30Height 30

Size To Fit

Page 101: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Row Layout

Page 102: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Row Layout

Groups with horizontal layout

Page 103: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Table Row Layout

Groups with horizontal layoutFine tune• Alignment• Insets and spacing• Sizing

Page 104: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Page 105: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Number inside circle Label

Page 106: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Page 107: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Group with horizontal layout

Page 108: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Group with horizontal layoutLabel

Page 109: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Group with horizontal layoutLabel

Page 110: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Ingredients Controller

Nested GroupLabel

Page 111: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups Can Have Backgrounds

Label

Page 112: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups Can Have Backgrounds

Group withblue background and radius of 8

Label

Page 113: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment of Number Label

10 Label

Page 114: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment of Number Label

10Centered in group Label

Page 115: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

10 Label

Page 116: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Left Inset 10 Label

Page 117: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Bottom Inset

10 Label

Page 118: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Top Inset

10 Label

Page 119: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Insets and Spacing

Spacing

10 Label

Page 120: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Page 121: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Nested groups

Page 122: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Nested groupsGroups with background

Page 123: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Nested groupsGroups with background • Color• Images

Page 124: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Servings Controller

Page 125: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Servings Controller

Circular layout

Page 126: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Servings Controller

Circular layoutLabel

Page 127: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Layout for Servings Controller

4

Page 128: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Three Top-Level Groups

Page 129: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Three Top-Level Groups

Page 130: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Three Top-Level Groups

4

Page 131: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Three Top-Level Groups

4

Page 132: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Alignment and Sizing

4

Page 133: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Alignment and Sizing

4

Horizontal: CenterFixed Size

Page 134: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Group Alignment and Sizing

4

Horizontal: CenterFixed Size

Width relative to100% of container

Page 135: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Second Group Has Nested Groups

4

Page 136: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Second Group Has Nested Groups

4

Page 137: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Second Group Has Nested Groups

4

Page 138: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Second Group Has Nested Groups

4

Page 139: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Second Group Has Nested Groups

4

Page 140: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment Inside Groups

Page 141: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment Inside Groups

Page 142: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment Inside Groups

Horizontal: RightVertical: Top

Page 143: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment Inside Groups

Horizontal: LeftVertical: Center

Horizontal: RightVertical: Top

Page 144: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Alignment Inside Groups

Horizontal: RightVertical: Bottom

Horizontal: LeftVertical: Center

Horizontal: RightVertical: Top

Page 145: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Page 146: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Group nesting for complex layouts

Page 147: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Ingredients Controller Layout

Group nesting for complex layoutsDon’t abuse power of groups

Page 148: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

Page 149: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

WatchKit has no APIs for direct element creation

Page 150: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

WatchKit has no APIs for direct element creationWhat you describe in IB is created

Page 151: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

WatchKit has no APIs for direct element creationWhat you describe in IB is createdHidden objects

Page 152: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

WatchKit has no APIs for direct element creationWhat you describe in IB is createdHidden objects• Creation cost

Page 153: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Implications of Complex Layouts

WatchKit has no APIs for direct element creationWhat you describe in IB is createdHidden objects• Creation cost• Save on layout cost

Page 154: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Page 155: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Don’t ignore transfer costs

Page 156: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Don’t ignore transfer costs• watchOS 1 apps run extension on iPhone

Page 157: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Don’t ignore transfer costs• watchOS 1 apps run extension on iPhone• watchOS 2 apps need to install extension

Page 158: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Don’t ignore transfer costs• watchOS 1 apps run extension on iPhone• watchOS 2 apps need to install extension

Use appropriate sizes

Page 159: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Using Images in Layouts

Don’t ignore transfer costs• watchOS 1 apps run extension on iPhone• watchOS 2 apps need to install extension

Use appropriate sizesImage slicing can accommodate various sizes

Page 160: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animations

Tom Witkin WatchKit Engineer

Page 161: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Existing Methods of AnimationTables and animated images

Page 162: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesCertain updates already animate

Page 163: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesCertain updates already animate

Insert rows

Page 164: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesCertain updates already animate

Insert rowsRemove rows

Page 165: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesCertain updates already animate

Insert rowsRemove rowsUpdate row content

Page 166: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 167: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AlphabeticalRanking

Page 168: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AlphabeticalRanking

Page 169: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AlphabeticalRanking

Page 170: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AlphabeticalRanking

Page 171: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Tables

[self.recipeTable insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withRowType:@"status"]; StatusRowController *rc = [self.recipeTable rowControllerAtIndex:0]; [rc setText:text]; self.statusRowTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideStatusRow) userInfo:nil repeats:NO];

Insert and remove rows

Page 172: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

[self.recipeTable insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withRowType:@"status"]; StatusRowController *rc = [self.recipeTable rowControllerAtIndex:0]; [rc setText:text]; self.statusRowTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideStatusRow) userInfo:nil repeats:NO];

Page 173: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

[self.recipeTable insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withRowType:@"status"]; StatusRowController *rc = [self.recipeTable rowControllerAtIndex:0]; [rc setText:text]; self.statusRowTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideStatusRow) userInfo:nil repeats:NO];

Page 174: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

[self.recipeTable insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withRowType:@"status"]; StatusRowController *rc = [self.recipeTable rowControllerAtIndex:0]; [rc setText:text]; self.statusRowTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideStatusRow) userInfo:nil repeats:NO];

Page 175: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

Page 176: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

Insert or remove rows of any type

Page 177: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

Insert or remove rows of any typeTo avoid animations

setRowTypes() setNumberOfRows(_:, withRowType:)

Page 178: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesInsert and remove rows

Insert or remove rows of any typeTo avoid animations

setRowTypes() setNumberOfRows(_:, withRowType:)

Page 179: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 180: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 181: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 182: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 183: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 184: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 185: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Table Cell

Page 186: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 187: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

shortDescriptionLabel

Page 188: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

shortDescriptionLabel

moreLabel

Page 189: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

shortDescriptionLabel

moreLabel

fullDescriptionLabel

Page 190: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

shortDescriptionLabel

moreLabel

fullDescriptionLabel

Hidden Objects

Page 191: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

shortDescriptionLabel

moreLabel

fullDescriptionLabel

Hidden Objects

Page 192: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesReload row content

DescriptionRowController *rc = [self.table rowControllerAtIndex:0]; [rc.fullDescriptionLabel setHidden:NO]; [rc.shortDescriptionLabel setHidden:YES]; [rc.moreLabel setHidden:YES];

Page 193: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesReload row content

Page 194: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesReload row content

Rows reload when content changes in height

Page 195: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesReload row content

Rows reload when content changes in heightMake sure rows have size to fit height

Page 196: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

TablesReload row content

Rows reload when content changes in heightMake sure rows have size to fit height

Page 197: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 198: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 199: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 200: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 201: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 202: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 203: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animated Images

Page 204: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animated Images

Cycle through a series of images

Page 205: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animated Images

Cycle through a series of imagesRepeat and reverse animations

Page 206: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animated Images

Cycle through a series of imagesRepeat and reverse animationsOptimizing images is important• Reduce size and number of images

Page 207: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfacePicker

0%10%20%30%

Page 208: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

WKInterfacePicker

0%10%20%30%40%50%60%70%

Page 209: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Related Session

WatchKit In-Depth, Part 2 WWDC15 Videos

Page 210: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animation API

Page 211: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

Page 212: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

Opacity

Page 213: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

OpacityWidth / height

Page 214: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

OpacityWidth / heightAlignment

Page 215: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

OpacityWidth / heightAlignmentBackground color

Page 216: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

OpacityWidth / heightAlignmentBackground colorColor / tint color

Page 217: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animatable Properties

OpacityWidth / heightAlignmentBackground colorColor / tint colorGroup insets

Page 218: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

New APIWKInterfaceController

func animateWithDuration(duration: NSTimeInterval, animations: () -> Void)

Page 219: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Animation Examples

Page 220: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 221: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 222: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 223: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 224: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 225: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 226: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

for (NSInteger i = 0; i < self.outerGroups.count; i++) { WKInterfaceGroup *group = self.outerGroups[i]; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)delay); dispatch_after(time, dispatch_get_main_queue(), ^{

[self animateWithDuration:duration animations:^{ [group setAlpha:alpha]; }];

}); }

Page 227: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

for (NSInteger i = 0; i < self.outerGroups.count; i++) { WKInterfaceGroup *group = self.outerGroups[i]; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)delay); dispatch_after(time, dispatch_get_main_queue(), ^{

[self animateWithDuration:duration animations:^{ [group setAlpha:alpha]; }];

}); }

Page 228: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

for (NSInteger i = 0; i < self.outerGroups.count; i++) { WKInterfaceGroup *group = self.outerGroups[i]; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)delay); dispatch_after(time, dispatch_get_main_queue(), ^{

[self animateWithDuration:duration animations:^{ [group setAlpha:alpha]; }];

}); }

Page 229: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

for (NSInteger i = 0; i < self.outerGroups.count; i++) { WKInterfaceGroup *group = self.outerGroups[i]; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)delay); dispatch_after(time, dispatch_get_main_queue(), ^{

[self animateWithDuration:duration animations:^{ [group setAlpha:alpha]; }];

}); }

Page 230: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

New APIWKInterfaceController

- (void)didAppear; - (void)willDisappear;

Page 231: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

New APIWKInterfaceController

- (void)didAppear; - (void)willDisappear;

*Coming in a future watchOS 2 seed

Page 232: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

Page 233: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Sequential Animations

Page 234: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivate

Sequential Animations

Page 235: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivateStagger animations using timers or GCD

Sequential Animations

Page 236: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivateStagger animations using timers or GCD• Interface controller must be active

Sequential Animations

Page 237: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivateStagger animations using timers or GCD• Interface controller must be active• Keep total duration short

Sequential Animations

Page 238: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivateStagger animations using timers or GCD• Interface controller must be active• Keep total duration short

Set initial animation values in storyboard

Sequential Animations

Page 239: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Use -didAppear, not -willActivateStagger animations using timers or GCD• Interface controller must be active• Keep total duration short

Set initial animation values in storyboard

Sequential Animations

Page 240: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 241: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 242: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 243: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 244: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 245: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 246: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 247: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

numberBackground

Page 248: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

numberBackground textLabel

Page 249: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

numberBackgroundspacerGroup

textLabel

Page 250: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

spacerGroup

Page 251: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 252: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 253: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

textLabelnumberBackground

Page 254: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

[self animateWithDuration:0.3 animations:^{

for (NSInteger i = 0 ; i < self.instructionsTable.numberOfRows; i++) {

IngredientRowController *rowController = [self.instructionsTable rowControllerAtIndex:i];

[rowController.numberBackground setAlpha:1.0]; [rowController.textLabel setAlpha:1.0]; [rowController.spacerGroup setWidth:0.0];

}];

}

Page 255: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

[self animateWithDuration:0.3 animations:^{

for (NSInteger i = 0 ; i < self.instructionsTable.numberOfRows; i++) {

IngredientRowController *rowController = [self.instructionsTable rowControllerAtIndex:i];

[rowController.numberBackground setAlpha:1.0]; [rowController.textLabel setAlpha:1.0]; [rowController.spacerGroup setWidth:0.0];

}];

}

Page 256: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

[self animateWithDuration:0.3 animations:^{

for (NSInteger i = 0 ; i < self.instructionsTable.numberOfRows; i++) {

IngredientRowController *rowController = [self.instructionsTable rowControllerAtIndex:i];

[rowController.numberBackground setAlpha:1.0]; [rowController.textLabel setAlpha:1.0]; [rowController.spacerGroup setWidth:0.0];

}];

}

Page 257: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

[self animateWithDuration:0.3 animations:^{

for (NSInteger i = 0 ; i < self.instructionsTable.numberOfRows; i++) {

IngredientRowController *rowController = [self.instructionsTable rowControllerAtIndex:i];

[rowController.numberBackground setAlpha:1.0]; [rowController.textLabel setAlpha:1.0]; [rowController.spacerGroup setWidth:0.0];

}];

}

Page 258: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 259: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Page 260: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Invisible spacer groups

Page 261: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Invisible spacer groupsAdjust width, height, or alignment

Page 262: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Invisible spacer groupsAdjust width, height, or alignmentAnimating will re-layout entire interface

Page 263: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Groups as Spacing Elements

Invisible spacer groupsAdjust width, height, or alignmentAnimating will re-layout entire interface

Page 264: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 265: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 266: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 267: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 268: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 269: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 270: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 271: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 272: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 273: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 274: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 275: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

Page 276: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

Page 277: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

textBubble

Page 278: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

textBubble

confirmationButton

Page 279: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

Page 280: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

textContainer

Complex Interface Transitions

Page 281: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

textBubble

confirmationButton

Complex Interface Transitions

Page 282: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textBubble setRelativeWidth:1.0 withAdjustment:0.0]; [self.textBubble sizeToFitHeight]; [self.textBubble setAlpha:1.0];

[self.confirmationButton setAlpha:1.0];

[self.textContainer sizeToFitHeight];

}];

Page 283: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textBubble setRelativeWidth:1.0 withAdjustment:0.0]; [self.textBubble sizeToFitHeight]; [self.textBubble setAlpha:1.0];

[self.confirmationButton setAlpha:1.0];

[self.textContainer sizeToFitHeight];

}];

Page 284: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textBubble setRelativeWidth:1.0 withAdjustment:0.0]; [self.textBubble sizeToFitHeight]; [self.textBubble setAlpha:1.0];

[self.confirmationButton setAlpha:1.0];

[self.textContainer sizeToFitHeight];

}];

Page 285: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textBubble setRelativeWidth:1.0 withAdjustment:0.0]; [self.textBubble sizeToFitHeight]; [self.textBubble setAlpha:1.0];

[self.confirmationButton setAlpha:1.0];

[self.textContainer sizeToFitHeight];

}];

Page 286: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textBubble setRelativeWidth:1.0 withAdjustment:0.0]; [self.textBubble sizeToFitHeight]; [self.textBubble setAlpha:1.0];

[self.confirmationButton setAlpha:1.0];

[self.textContainer sizeToFitHeight];

}];

Page 287: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 288: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and
Page 289: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

Page 290: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

Page 291: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

confirmationContainer

Page 292: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

confirmationContainer

textContainer

Page 293: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

textContainer

confirmationContainer

Page 294: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textContainer setAlpha:0.0]; [self.textContainer setHeight:0.0];

[self.confirmationContainer setRelativeHeight:1.0 withAdjustment:0.0];

}];

Page 295: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textContainer setAlpha:0.0]; [self.textContainer setHeight:0.0];

[self.confirmationContainer setRelativeHeight:1.0 withAdjustment:0.0];

}];

Page 296: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textContainer setAlpha:0.0]; [self.textContainer setHeight:0.0];

[self.confirmationContainer setRelativeHeight:1.0 withAdjustment:0.0];

}];

Page 297: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Complex Interface Transitions

[self animateWithDuration:duration animations:^{

[self.textContainer setAlpha:0.0]; [self.textContainer setHeight:0.0];

[self.confirmationContainer setRelativeHeight:1.0 withAdjustment:0.0];

}];

Page 298: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Page 299: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Any update that affects sizing can animate layout

Page 300: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Any update that affects sizing can animate layout• Example—WKInterfaceLabel text

Page 301: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Any update that affects sizing can animate layout• Example—WKInterfaceLabel text

Concurrent animations and complex layouts affect performance

Page 302: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Any update that affects sizing can animate layout• Example—WKInterfaceLabel text

Concurrent animations and complex layouts affect performance• Test on hardware!

Page 303: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few notes

Any update that affects sizing can animate layout• Example—WKInterfaceLabel text

Concurrent animations and complex layouts affect performance• Test on hardware!

API functions within apps, not Glances or dynamic notifications

Page 304: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few more notes

Page 305: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few more notes

Use with restraint

Page 306: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few more notes

Use with restraintShould never be the focus

Page 307: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

AnimationA few more notes

Use with restraintShould never be the focusKeep duration short

Page 308: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Related Session

Designing with Animation Presidio Thursday 3:30PM

Page 309: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Page 310: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout

Page 311: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time

Page 312: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based

Page 313: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based• Groups are powerful

Page 314: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based• Groups are powerful

Animation

Page 315: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based• Groups are powerful

Animation• Add liveliness and feedback to your app

Page 316: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based• Groups are powerful

Animation• Add liveliness and feedback to your app• Tables and images can already animate

Page 317: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Summary

Layout• Specified at design time• Flow-based• Groups are powerful

Animation• Add liveliness and feedback to your app• Tables and images can already animate• New API in watchOS 2

Page 318: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

More Information

DocumentationwatchOS 2 Transition GuideWatchKit Programming Guide

Sample CodeWKRecipesWatchKit Cataloghttp://developer.apple.com/watchOS

Technical SupportApple Developer ForumsDeveloper Technical Support

General InquiriesJake Behrens,watchOS Frameworks [email protected]

Page 319: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Related Sessions

Introducing WatchKit for watchOS 2 WWDC15 Videos

Building Watch Apps WWDC15 Videos

WatchKit In-Depth, Part 1 WWDC15 Videos

WatchKit In-Depth, Part 2 WWDC15 Videos

Designing for Apple Watch WWDC15 Videos

WatchKit Tips and Tricks Presidio Friday 10:00AM

Apple Watch Design Tips and Tricks Presidio Friday 3:30PM

Page 320: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and

Labs

WatchKit Layout and Animation Lab Frameworks Lab B Thursday 3:30PM

WatchKit and ClockKit Complications Lab Frameworks Lab A Friday 1:30PM

Page 321: Layout and Animation Techniques For WatchKit...WatchKit Layout Programming Model You don’t write object creation code Fine tuned control of: • Layout hierarchy • Alignment and