creating custom ios user interfaces€¦ · used for nearly every system animation starting in ios...

196
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC14 Creating Custom iOS User Interfaces Make your app stand out Session 221 Brandon Newendorp iOS Software Engineer Frameworks

Upload: others

Post on 06-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

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

#WWDC14

Creating Custom iOS User InterfacesMake your app stand out

Session 221 Brandon Newendorp iOS Software Engineer

Frameworks

Page 2: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 3: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 4: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 5: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Questions to ask

Page 6: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Questions to ask

Where will this be used?

Page 7: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Questions to ask

Where will this be used?

Does it need to support multiple states?

Page 8: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Questions to ask

Where will this be used?

Does it need to support multiple states?

Can this be shared across several apps?

Page 9: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Questions to ask

Where will this be used?

Does it need to support multiple states?

Can this be shared across several apps?

What APIs can be leveraged?

Page 10: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

Page 11: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

UIAppearance

Page 12: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

UIAppearance• UIImageRenderingMode

Page 13: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

UIAppearance• UIImageRenderingMode

Dynamic Type

Page 14: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

UIAppearance• UIImageRenderingMode

Dynamic Type

Accessibility

Page 15: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

When Should You Build Custom UI?Take advantage of existing API

UIAppearance• UIImageRenderingMode

Dynamic Type

Accessibility

Localization

Page 16: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Agenda

Page 17: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Agenda

Spring animations

Page 18: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Agenda

Spring animations

Vibrancy and blur

Page 19: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Agenda

Spring animations

Vibrancy and blur

Shape layers

Page 20: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Agenda

Spring animations

Vibrancy and blur

Shape layers

Dynamic Core Animation behaviors

Page 21: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsMore natural animation curves

Page 22: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Page 23: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Not necessarily a bouncy, spring-like behavior

Page 24: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Not necessarily a bouncy, spring-like behavior

Different timing curve for animations

Page 25: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Not necessarily a bouncy, spring-like behavior

Different timing curve for animations

Used for nearly every system animation starting in iOS 7

Page 26: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Not necessarily a bouncy, spring-like behavior

Different timing curve for animations

Used for nearly every system animation starting in iOS 7

Don’t require the use of UIKit Dynamics

Page 27: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat are they?

Not necessarily a bouncy, spring-like behavior

Different timing curve for animations

Used for nearly every system animation starting in iOS 7

Don’t require the use of UIKit Dynamics

Nearly the same API as UIView’s animateWithDuration:

Page 28: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Ease in/out Spring

Page 29: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Ease in/out Spring

Page 30: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Ease in/out Spring

Page 31: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Ease in/out Spring

Page 32: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhat they do

0

100

200

300

400

Default

Page 33: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

0

100

200

300

400

Default Spring

Spring AnimationsWhat they do

Page 34: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

0

100

200

300

400

Default Spring

Spring AnimationsWhat they do

Page 35: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 36: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 37: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 38: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 39: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 40: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 41: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsAPI

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Page 42: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsAPI

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Page 43: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.1

Page 44: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.1

Page 45: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.5

Page 46: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.5

Page 47: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.8

Page 48: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.8

Page 49: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0

Page 50: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0

Page 51: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0 initialVelocity = 20.0

Page 52: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0 initialVelocity = 20.0

Page 53: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0 initialVelocity = 40.0

Page 54: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 1.0 initialVelocity = 40.0

Page 55: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.2 initialVelocity = 15.0

Page 56: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

damping = 0.2 initialVelocity = 15.0

Page 57: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Page 58: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Great substitute for linear animations

Page 59: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Great substitute for linear animations

Any place you want to fit in with native UIKit controls

Page 60: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Great substitute for linear animations

Any place you want to fit in with native UIKit controls

Used for nearly all animations in iOS

Page 61: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Great substitute for linear animations

Any place you want to fit in with native UIKit controls

Used for nearly all animations in iOS

Make controls feel more natural

Page 62: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Spring AnimationsWhere might you use them?

Great substitute for linear animations

Any place you want to fit in with native UIKit controls

Used for nearly all animations in iOS

Make controls feel more natural

Applies to any animatable property, not just position

Page 63: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

DemoSpring animations

Page 64: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewAsk and ye shall receive

Page 65: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering in iOSA brief aside

Page 66: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 67: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 68: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Page 69: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Set up and perform view layout

Page 70: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Set up and perform view layout

View and string drawing

Page 71: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Set up and perform view layout

View and string drawing

Additional Core Animation work

Page 72: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Set up and perform view layout

View and string drawing

Additional Core Animation work

Package up layers and send them to render server

Page 73: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Commit TransactionIn your app

Set up and perform view layout

View and string drawing

Additional Core Animation work

Package up layers and send them to render server

• Advanced Graphics and Animations in iOS Apps Russian Hill Tuesday 10:15AM

Page 74: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewAsk and ye shall receive

Page 75: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Fast, Static BlurdrawViewHierarchyInRect:afterScreenUpdates:

Page 76: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Fast, Static BlurdrawViewHierarchyInRect:afterScreenUpdates:

Last year presented a technique for blur effects

• Implementing Engaging UI on iOS 7 WWDC 2013

Page 77: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Fast, Static BlurdrawViewHierarchyInRect:afterScreenUpdates:

Last year presented a technique for blur effects

Recommended if blurred content doesn’t need to change

Page 78: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Fast, Static BlurdrawViewHierarchyInRect:afterScreenUpdates:

Last year presented a technique for blur effects

Recommended if blurred content doesn’t need to change

Highly optimized

Page 79: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewIntro

Page 80: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewIntro

New API for creating visual effects

Page 81: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewIntro

New API for creating visual effects

Two effect types

Page 82: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewIntro

New API for creating visual effects

Two effect types• Live blur

Page 83: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewIntro

New API for creating visual effects

Two effect types• Live blur

• Vibrancy

Page 84: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 85: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:
Page 86: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Page 87: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Three styles

Page 88: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Three styles • Dark

Page 89: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Three styles • Dark

• Light

Page 90: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Three styles • Dark

• Light

• ExtraLight

Page 91: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

Page 92: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

More than a simple Gaussian blur

Page 93: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

More than a simple Gaussian blur

Downsample

Page 94: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

More than a simple Gaussian blur

Downsample

Modify colors

Page 95: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIBlurEffect

More than a simple Gaussian blur

Downsample

Modify colors

Compute blurs

Page 96: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Page 97: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Creates legible content above blurs

Page 98: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Creates legible content above blurs

Boost saturation

Page 99: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Creates legible content above blurs

Boost saturation

Custom blend mode

Page 100: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Creates legible content above blurs

Boost saturation

Custom blend mode

Behavior changes based on backing blur

Page 101: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewUIVibrancyEffect

Creates legible content above blurs

Boost saturation

Custom blend mode

Behavior changes based on backing blur

Only supported with a blur effect

Page 102: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Page 103: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Create a UIVisualEffect

Page 104: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Create a UIVisualEffect• UIBlurEffect

Page 105: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Create a UIVisualEffect• UIBlurEffect

• UIVibrancyEffect—takes a blur in the initializer

Page 106: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Create a UIVisualEffect• UIBlurEffect

• UIVibrancyEffect—takes a blur in the initializer

Create a UIVisualEffectView with a UIVisualEffect

Page 107: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewHow to use?

Create a UIVisualEffect• UIBlurEffect

• UIVibrancyEffect—takes a blur in the initializer

Create a UIVisualEffectView with a UIVisualEffect

Add subviews to its contentView

Page 108: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCustomizability

Page 109: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCustomizability

Tint blurs by changing backgroundColor on contentView

Page 110: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCustomizability

Tint blurs by changing backgroundColor on contentView

Animate frame changes

Page 111: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Page 112: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Setting alpha is at odds with blur

Page 113: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Setting alpha is at odds with blur

Avoid placing a UIVisualEffectView in a view hierarchy that contains masks

Page 114: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Setting alpha is at odds with blur

Avoid placing a UIVisualEffectView in a view hierarchy that contains masks

Beware of groups that can affect your UIVisualEffectView

Page 115: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Setting alpha is at odds with blur

Avoid placing a UIVisualEffectView in a view hierarchy that contains masks

Beware of groups that can affect your UIVisualEffectView• Animation groups

Page 116: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewCaveats

Setting alpha is at odds with blur

Avoid placing a UIVisualEffectView in a view hierarchy that contains masks

Beware of groups that can affect your UIVisualEffectView• Animation groups

• Opacity groups

Page 117: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 118: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 119: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Page 120: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Standard view

Page 121: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Standard view

Blur effect

Page 122: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Blur effect with vibrancy

Standard view

Blur effect

Page 123: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Blur effect with vibrancy

Standard view

Blur effect

Page 124: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

UIVisualEffectViewRendering cost

Blur effect with vibrancy

Standard view

Blur effect

Standard view with static blur

Page 125: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

DemoUIVisualEffectView

Page 126: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerA great way to draw custom content

Page 127: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Page 128: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Powerful tool to draw custom Bézier paths

Page 129: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Powerful tool to draw custom Bézier paths

CALayer subclass, easy to use in existing view hierarchies

Page 130: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Powerful tool to draw custom Bézier paths

CALayer subclass, easy to use in existing view hierarchies

Animatable

Page 131: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Page 132: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerWhy is it useful?

Page 133: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

Page 134: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

@property CGPathRef path;

Page 135: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

bezierPath = [UIBezierPath bezierPath]; !

[bezierPath moveToPoint:CGPointMake(0, 220)]; [bezierPath addCurveToPoint: CGPointMake(160, 115) controlPoint1:CGPointMake(0, 220) controlPoint2:CGPointMake(15, 100)]; [bezierPath addCurveToPoint: CGPointMake(305, 20) controlPoint1:CGPointMake(300, 132) controlPoint2:CGPointMake(305, 20)]; [shapeLayer setPath:bezierPath.CGPath];

Page 136: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

bezierPath = [UIBezierPath bezierPath]; !

[bezierPath moveToPoint:CGPointMake(0, 220)]; [bezierPath addCurveToPoint: CGPointMake(160, 115) controlPoint1:CGPointMake(0, 220) controlPoint2:CGPointMake(15, 100)]; [bezierPath addCurveToPoint: CGPointMake(305, 20) controlPoint1:CGPointMake(300, 132) controlPoint2:CGPointMake(305, 20)]; [shapeLayer setPath:bezierPath.CGPath];

Page 137: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

bezierPath = [UIBezierPath bezierPath]; !

[bezierPath moveToPoint:CGPointMake(0, 220)]; [bezierPath addCurveToPoint: CGPointMake(160, 115) controlPoint1:CGPointMake(0, 220) controlPoint2:CGPointMake(15, 100)]; [bezierPath addCurveToPoint: CGPointMake(305, 20) controlPoint1:CGPointMake(300, 132) controlPoint2:CGPointMake(305, 20)]; [shapeLayer setPath:bezierPath.CGPath];

Page 138: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

bezierPath = [UIBezierPath bezierPath]; !

[bezierPath moveToPoint:CGPointMake(0, 220)]; [bezierPath addCurveToPoint: CGPointMake(160, 115) controlPoint1:CGPointMake(0, 220) controlPoint2:CGPointMake(15, 100)]; [bezierPath addCurveToPoint: CGPointMake(305, 20) controlPoint1:CGPointMake(300, 132) controlPoint2:CGPointMake(305, 20)]; [shapeLayer setPath:bezierPath.CGPath];

Page 139: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerPath

bezierPath = [UIBezierPath bezierPath]; !

[bezierPath moveToPoint:CGPointMake(0, 220)]; [bezierPath addCurveToPoint: CGPointMake(160, 115) controlPoint1:CGPointMake(0, 220) controlPoint2:CGPointMake(15, 100)]; [bezierPath addCurveToPoint: CGPointMake(305, 20) controlPoint1:CGPointMake(300, 132) controlPoint2:CGPointMake(305, 20)]; [shapeLayer setPath:bezierPath.CGPath];

Page 140: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerLine

lineCap lineDashPattern lineDashPhase

Page 141: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerLine

lineCap lineDashPattern lineDashPhase

Page 142: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerLine

lineCap lineDashPattern lineDashPhase

[shapeLayer setLineCap:kCALineCapRound]

Page 143: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerLine

lineCap lineDashPattern lineDashPhase

[shapeLayer setLineDashPattern:@[@2, @4, @6, @6]]

Page 144: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerLine

lineCap lineDashPattern lineDashPhase

[shapeLayer setLineDashPattern:@[@2, @4, @6, @6]] [shapeLayer setLineDashPhase:4.0]

Page 145: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerStroke

strokeColor strokeBegin strokeEnd

Page 146: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerStroke

strokeColor strokeBegin strokeEnd

[shapeLayer setStrokeColor:[UIColor redColor].CGColor]

Page 147: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerStroke

strokeColor strokeBegin strokeEnd

[shapeLayer setStrokeStart:0.2]

Page 148: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerStroke

strokeColor strokeBegin strokeEnd

[shapeLayer setStrokeEnd:0.6]

Page 149: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerFill

fillColor

Page 150: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerFill

fillColor

[shapeLayer setFillColor:[UIColor yellowColor].CGColor]

Page 151: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 152: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Rendering Pipeline

Handle events, commit transaction

Process transaction, composite layers

Render

Display render results

Application

Render server

GPU

Display

Page 153: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Page 154: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Rasterizes shape layer on CPU

Page 155: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Rasterizes shape layer on CPU

Sends rasterized layer to render server

Page 156: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Rasterizes shape layer on CPU

Sends rasterized layer to render server

Can be expensive in CPU time

Page 157: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Rasterizes shape layer on CPU

Sends rasterized layer to render server

Can be expensive in CPU time

Use more layers with less complexity

Page 158: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CAShapeLayerRendering in your app

Rasterizes shape layer on CPU

Sends rasterized layer to render server

Can be expensive in CPU time

Use more layers with less complexity

Be cautious about frequent changes

Page 159: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

DemoCAShapeLayer

Page 160: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsModifying implicit animations

Page 161: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsDid you know?

Page 162: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsDid you know?

UIKit supports most animations

Page 163: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsDid you know?

UIKit supports most animations

Core Animation provides implicit animations on layers

Page 164: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsDid you know?

UIKit supports most animations

Core Animation provides implicit animations on layers

Have the ability to override implicit Core Animation behaviors

Page 165: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Page 166: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Page 167: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Changing the behavior of default animations

Page 168: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Changing the behavior of default animations• Show a color while animating opacity

Page 169: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Changing the behavior of default animations• Show a color while animating opacity

• Use a non-linear path for changing position

Page 170: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Changing the behavior of default animations• Show a color while animating opacity

• Use a non-linear path for changing position

Animating new properties on a custom CALayer

Page 171: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsWhat could you do?

Disable implicit animations

Changing the behavior of default animations• Show a color while animating opacity

• Use a non-linear path for changing position

Animating new properties on a custom CALayer

Define behaviors that are inherent to a custom view

Page 172: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

CALayer

MyView

Page 173: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

Page 174: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

Page 175: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

[UIView animateWithDuration:1.0 animations:^{ [MyView setAlpha:0.2]; };

Page 176: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

Page 177: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer- (id<CAAction>)actionForLayer:forKey:

Page 178: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CALayer

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

Page 179: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

CALayer

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

[super actionForLayer:layer key:event]

Page 180: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

Page 181: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation Behaviors

MyView <CALayerDelegate>

CALayer

MyAction <CAAction>

Page 182: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsCAAction protocol

- (void)runActionForKey:(NSString *)key object:(id)anObject arguments:(NSDictionary *)dict

Page 183: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsCAAction protocol

- (void)runActionForKey:(NSString *)key object:(id)anObject arguments:(NSDictionary *)dict

Implement CAAction on any object

Page 184: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsCAAction protocol

- (void)runActionForKey:(NSString *)key object:(id)anObject arguments:(NSDictionary *)dict

Implement CAAction on any object

Perform animations in the implementation

Page 185: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsCAAction protocol

- (void)runActionForKey:(NSString *)key object:(id)anObject arguments:(NSDictionary *)dict

!

Specifies the property that has changed

Page 186: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Dynamic Core Animation BehaviorsCAAction protocol

- (void)runActionForKey:(NSString *)key object:(id)anObject arguments:(NSDictionary *)dict

!

Provides a reference to the layer being animated

Page 187: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

DemoCAAction

Page 188: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Summary

Page 189: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Summary

Spring animations

Page 190: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Summary

Spring animations

UIVisualEffectView

Page 191: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Summary

Spring animations

UIVisualEffectView

CAShapeLayer

Page 192: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Summary

Spring animations

UIVisualEffectView

CAShapeLayer

Dynamic Core Animation behaviors

Page 193: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

More Information

Jake Behrens App Frameworks Evangelist [email protected]

Documentation UIKit Framework Reference Core Animation Programming Guide http://developer.apple.com

Apple Developer Forums http://devforums.apple.com

Page 194: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Related Sessions

• Accessibility on iOS Russian Hill Tuesday 3:15PM

• Advanced Topics in Internationalization Russian Hill Tuesday 9:00AM

• Localizing with Xcode 6 Marina Tuesday 11:30AM

• Advanced Graphics and Animations for iOS App Russian Hill Tuesday 10:15AM

• Building Interruptible and Responsive Interactions Presidio Friday 11:30AM

Page 195: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration:

Labs

• Visual Effects and Appearance Customization Lab Frameworks Lab A Friday 9:00AM

• Dynamics, View Animations, and Core Animation Lab

Frameworks Lab A Thursday 9:00AM

Page 196: Creating Custom iOS User Interfaces€¦ · Used for nearly every system animation starting in iOS 7 Don’t require the use of UIKit Dynamics Nearly the same API as UIView’s animateWithDuration: