SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
© 2015 WIRE SWISS GMBH
Advanced UI styling and animations for iOS
© 2015 WIRE SWISS GMBH
AdvancedUIstylingandanimationsforiOS
© 2014 WIRE SWISS GMBH
About the Author: Mike Gerasymenko
• Working on iOS since 2008 (iOS 2.2)
• Around 35 apps for the AppStore
• With Wire since March 2014
© 2014 WIRE SWISS GMBH
Disclaimer
• A lot of open-source code is used
• Not all presented is created at Wire
• We love open-source and we do pull
requests and share the things we
develop
• github.com/wearezeta
© 2014 WIRE SWISS GMBH
Follow-Up on Cristobal’s presentation
• Why I brought up this topic?
• Bring the Sense of continuity
• Broaden-up the insight for those
who was interested last time
• Give a deep insight on how UI
works in Wire
• Design is crucial
© 2015 WIRE SWISS GMBH
Plan
• Everything is Custom:
• Custom animation’s timings on UIViews and
CALayers
• Custom styling for the user interface
• One More Thing
© 2014 WIRE SWISS GMBH
Glossary
© 2014 WIRE SWISS GMBH
Animation timing (easing): functions
• Animation is a change of property from
initial (A) to end value (B) in given time (t)
• How the change is distributed over the
time t?
• Timing curve (Easing):
• Gives animation progress for time
• Implementation:
• UIView: predefined set of timing curves
• CoreAnimation: can be defined as
arbitrary Bézier curve that starts in (0,
0) and ends in (1, 1), so two control
points can vary
© 2014 WIRE SWISS GMBH
Animation timing (easing): functions
• Animation is a change of property from
initial (A) to end value (B) in given time (t)
• How the change is distributed over the
time t?
• Timing curve (Easing):
• Gives animation progress for time
• Implementation:
• UIView: predefined set of timing curves
• CoreAnimation: can be defined as
arbitrary Bézier curve that starts in (0,
0) and ends in (1, 1), so two control
points can vary
© 2014 WIRE SWISS GMBH
Animation timing (easing): example
© 2014 WIRE SWISS GMBH
Animation timing (easing): custom timing
Why custom timing function is important?

Because designers says so

Because it looks better and makes the difference

How we can use custom timing function with UIView animation?

We can’t, it is not supported by the API
?
© 2015 WIRE SWISS GMBH
Animation timing (easing): Math 101
• Bezier curves are defined as power functions
• Exponential functions are the different set of
functions
• Use «Best Fitting» Bezier curves, would be not
equal to expo but close enough
• Root mean squared error is as low as 0.00000102
( ) ( )( )( ) ( )
( ) tttt dxxfy 1
1
0
2
∫ −
© 2014 WIRE SWISS GMBH
The Problem
© 2015 WIRE SWISS GMBH
Animation timing (easing)
• UIView animations do not support
custom easing
• CoreAnimation API is complicated
and bulky
• We need to implement the API that
would work as UIView, but support
passing in the custom easing
© 2015 WIRE SWISS GMBH
Animation timing (easing): UIView animation 101
• UIViews are using CALayers (.layer from CoreAnimation framework) to display it’s contents
• CALayers are using CAAnimation family to do animations
• Conclusion: when UIView animation is created the backing animation is CAAnimation anyway
• We need to find a way to create CAAnimations like iOS do:
1 [UIView animateWithDuration: timingFunction: animations:^{
2 view.property = newValue;
3 }]
and produce the CAAnimations on the appropriate objects
© 2015 WIRE SWISS GMBH
Animation timing (easing): Introducing UIView+ExtendedBlockAnimations
• Approach:
• Swizzle -[CALayer actionForLayer:forKey:]
• When animation method is called, call UIView animation
block with the same parameters and expect it to create
the animations on CALayers
• Capture when UIView creates it’s animations
• Replace created animations with our own animations that
are utilising the custom timing functions
© 2014 WIRE SWISS GMBH
To The Code
© 2015 WIRE SWISS GMBH
Animation timing (easing): Preparation
Swizzle:
1 SEL originalSelector = @selector(actionForLayer:forKey:);
2 SEL extendedSelector = @selector(WR_actionForLayer:forKey:);
3
4 Method originalMethod = class_getInstanceMethod(self, originalSelector);
5 Method extendedMethod = class_getInstanceMethod(self, extendedSelector);
6
7 method_exchangeImplementations(originalMethod, extendedMethod);
Apply:
1 - (id<CAAction>)WR_actionForLayer:(CALayer *)layer forKey:(NSString *)event
2 {
3 ...
4 if (currentContext == BlockAnimationsContext &&
5 [supportedProperties containsObject:event]) {
6
7 [savedAnimations addObject:[WRSavedAnimationState savedStateWithLayer:layer
8 keyPath:event]];
9
10 // no implicit animation (it will be added later)
11 return (id<CAAction>)[NSNull null];
12 }
13 ...
14 }
© 2015 WIRE SWISS GMBH
Animation timing (easing): application
1 + (void)wr_animateWithEasing:(RBBEasingFunction)easing
2 duration:(NSTimeInterval)duration
3 delay:(NSTimeInterval)delay
4 animations:(void (^)(void))animations
5 options:(WRExtendedBlockAnimationsOptions)options
6 completion:(void (^)(BOOL finished))completion
7 {
8 RBBTweenAnimation *animation = [[RBBTweenAnimation alloc] init]; // create the template anim
9 animation.easing = easing;
10 ...
11
12 [self wr_animateWithBasicAnimation:animation
13 duration:duration
14 animations:animations
15 options:options
16 completion:completion];
17 }
© 2015 WIRE SWISS GMBH
Animation timing (easing): easy as 1-2-3
1 [UIView wr_animateWithEasing:RBBEasingFunctionEaseInExpo duration:0.35 delay:0 animations:^{
2 // Do animations
3 view.frame = newFrame;
4 view.alpha = 1.0f;
5 view.transform = newTransform;
6 } completion:^(BOOL finished) {
7 // Do completion
8 }];
© 2014 WIRE SWISS GMBH
© 2014 WIRE SWISS GMBH
Animation timing (easing)
Grab it at goo.gl/uYItrG
© 2014 WIRE SWISS GMBH
Questions
© 2014 WIRE SWISS GMBH
Interface Styling
Defining User Interface style
© 2014 WIRE SWISS GMBH
Interface Styling: What we need?
• Ability to define UI element’s style:
• Colour
• Font
• Insets
• Any other style-related property
• Per element objc-class, class, parent
• Ability to tweak style during runtime
• Clean stylesheet format
© 2014 WIRE SWISS GMBH
Interface Styling: Classy!
✓ Ability to define UI element’s style:
✓ Colour
✓ Font
✓ Insets
✓ Any other style-related property
✓ Per element objc-class, class, parent
✓ Ability to tweak style during runtime
✓ Clean stylesheet format
© 2014 WIRE SWISS GMBH
– http://cloudkite.github.io/Classy/
“Not CSS. Instead of trying to force UIKit to fit CSS syntax,
properties, conventions and constructs. Classy is a
stylesheet system built from the ground up to work in
harmony with UIKit. It borrows the best ideas from CSS and
introduces new syntax, conventions and constructs where
appropriate.”
Interface Styling: Classy!
© 2014 WIRE SWISS GMBH
Interface Styling: Classy integration
• Steps to integrate Classy:
• Grab framework via
• CocoaPods: pod 'Classy', '~> 0.2.4’
• Carthage: github "cloudkite/Classy"
• Create stylesheet
• Insert minimal initialisation code
• Profit!
© 2014 WIRE SWISS GMBH
Interface Styling: Classy stylesheet
1 @import "colors.cas";
2
3 $accentColor = #acacac;
4
5 // Supports custom UIView subclasses
6 WireView {
7 background-color: $accentColor;
8 title-insets: 5, 10, 5, 10;
9 > UIProgressView.tinted {
10 progress-tint-color: rgb(200, 155, 110, 0.6);
11 track-tint-color: yellow;
12 }
13 }
14
15 ^UIButton.warning, UIView.warning ^UIButton {
16 title-color[state:highlighted]: #e3e3e3;
27 }
© 2014 WIRE SWISS GMBH
Interface Styling: Classy selectors
• Selectors:
• Runtime class name
• cas_styleClass class
• Containment
• Property of
• Selectors can be mixed
© 2014 WIRE SWISS GMBH
Interface Styling: Classy properties
• Properties supported:
• Any system or user-defined
• Property types supported:
• UIColor
• UIFont
• UIEdgeInsets
• Any custom property
© 2014 WIRE SWISS GMBH
Interface Styling: Classy in the nutshell
+ Classy =
Un-Styled UI
Different themes
or
© 2014 WIRE SWISS GMBH
Interface Styling: Classy testing
• Selectors and properties
• Covered by unit and integration
tests
• We commit to Classy with PRs;
adding more test coverage to
the product
© 2014 WIRE SWISS GMBH
One more thing
© 2014 WIRE SWISS GMBH
Interface Styling: Classy live editing
• Classy can observe the filesystem
changes on the stylesheet and re-apply
the updates live
• Knowing that we added the WebDAV
client in the application’s development
builds
• Now design people can tweak certain
properties realtime using the iPhone, dev
build and their mac with a text editor
© 2014 WIRE SWISS GMBH
Questions
© 2014 WIRE SWISS GMBH
© 2014 WIRE SWISS GMBH
Regards to my fellow colleagues
Cristobal Castilla
Jacob Persson
Vjacheslav Volodko
Alan Duric
Marke Saaremets
Natalia Dorozala
© 2014 WIRE SWISS GMBH
Contact data
Mike Gerasymenko
mihail@gerasimenko.me
(find me on Wire using this email)
mike@wire.com
© 2014 WIRE SWISS GMBH

Mais conteúdo relacionado

Destaque

честь имею
честь имеючесть имею
честь имеюelvira38
 
HomeSun Solar Buy Brochure
HomeSun Solar Buy BrochureHomeSun Solar Buy Brochure
HomeSun Solar Buy BrochureKP4422
 
Senior Project
Senior ProjectSenior Project
Senior Projectbatboy1993
 
Hout plaatmateriaal
Hout plaatmateriaalHout plaatmateriaal
Hout plaatmateriaalkjill
 
De kracht van crownsourcing met kgi
De kracht van crownsourcing met kgiDe kracht van crownsourcing met kgi
De kracht van crownsourcing met kgiQuietroom Label
 
Развитие финансового сектора Казахстана в посткризисный период
Развитие финансового сектора Казахстана в посткризисный периодРазвитие финансового сектора Казахстана в посткризисный период
Развитие финансового сектора Казахстана в посткризисный периодАО "Самрук-Казына"
 
Lommi: Kouluterveyskysely 2011 Vakka-Suomessa
Lommi: Kouluterveyskysely 2011 Vakka-SuomessaLommi: Kouluterveyskysely 2011 Vakka-Suomessa
Lommi: Kouluterveyskysely 2011 Vakka-SuomessaKouluterveyskysely
 
Elements, Compounds & Mixtures - Day 1
Elements, Compounds & Mixtures - Day 1Elements, Compounds & Mixtures - Day 1
Elements, Compounds & Mixtures - Day 1jmori1
 
베트남 노동법 주요내용
베트남 노동법 주요내용베트남 노동법 주요내용
베트남 노동법 주요내용Nguyễn Khang
 
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...ClarkDurant
 
Themes ways of the world
Themes ways of the worldThemes ways of the world
Themes ways of the worldashleighalece
 
Welcome in Turin
Welcome in TurinWelcome in Turin
Welcome in Turinenzoppi
 

Destaque (17)

честь имею
честь имеючесть имею
честь имею
 
HomeSun Solar Buy Brochure
HomeSun Solar Buy BrochureHomeSun Solar Buy Brochure
HomeSun Solar Buy Brochure
 
Unit 7 y 8
Unit 7 y 8Unit 7 y 8
Unit 7 y 8
 
Senior Project
Senior ProjectSenior Project
Senior Project
 
Hout plaatmateriaal
Hout plaatmateriaalHout plaatmateriaal
Hout plaatmateriaal
 
Lecture2
Lecture2Lecture2
Lecture2
 
De kracht van crownsourcing met kgi
De kracht van crownsourcing met kgiDe kracht van crownsourcing met kgi
De kracht van crownsourcing met kgi
 
Развитие финансового сектора Казахстана в посткризисный период
Развитие финансового сектора Казахстана в посткризисный периодРазвитие финансового сектора Казахстана в посткризисный период
Развитие финансового сектора Казахстана в посткризисный период
 
Lommi: Kouluterveyskysely 2011 Vakka-Suomessa
Lommi: Kouluterveyskysely 2011 Vakka-SuomessaLommi: Kouluterveyskysely 2011 Vakka-Suomessa
Lommi: Kouluterveyskysely 2011 Vakka-Suomessa
 
Elements, Compounds & Mixtures - Day 1
Elements, Compounds & Mixtures - Day 1Elements, Compounds & Mixtures - Day 1
Elements, Compounds & Mixtures - Day 1
 
베트남 노동법 주요내용
베트남 노동법 주요내용베트남 노동법 주요내용
베트남 노동법 주요내용
 
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...
Betsy DeVos, Spence Abraham, and Saul Anuzis endorse Clark Durant for U.S. Se...
 
Sd10 nadia alkhazaliah
Sd10   nadia alkhazaliahSd10   nadia alkhazaliah
Sd10 nadia alkhazaliah
 
1° simulado es sa 2016
1° simulado es sa 20161° simulado es sa 2016
1° simulado es sa 2016
 
Themes ways of the world
Themes ways of the worldThemes ways of the world
Themes ways of the world
 
Successes2009
Successes2009Successes2009
Successes2009
 
Welcome in Turin
Welcome in TurinWelcome in Turin
Welcome in Turin
 

Semelhante a Advanced UI styling and animations for iOS

CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CloudBees
 
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)CloudBees
 
Custom Swift Operators: The Good, the Bad and the Ugly
Custom Swift Operators: The Good, the Bad and the UglyCustom Swift Operators: The Good, the Bad and the Ugly
Custom Swift Operators: The Good, the Bad and the UglyMike Gerasymenko
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin formsSolTech, Inc.
 
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...Joseph Labrecque
 
Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...mfrancis
 
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Claire Townend Gee
 
Continuous Deployment of your Application - SpringOne Tour Dallas
Continuous Deployment of your Application - SpringOne Tour DallasContinuous Deployment of your Application - SpringOne Tour Dallas
Continuous Deployment of your Application - SpringOne Tour DallasVMware Tanzu
 
Adobe MAX 2015 - Giving Flash Professional Another Look
Adobe MAX 2015 - Giving Flash Professional Another LookAdobe MAX 2015 - Giving Flash Professional Another Look
Adobe MAX 2015 - Giving Flash Professional Another LookJoseph Labrecque
 
UX Design at the Speed of Thought
UX Design at the Speed of ThoughtUX Design at the Speed of Thought
UX Design at the Speed of ThoughtFITC
 
DSpace UI prototype dsember
DSpace UI prototype dsemberDSpace UI prototype dsember
DSpace UI prototype dsemberBram Luyten
 
Eclipse tools for deployment to was liberty profile in Bluemix
Eclipse tools for deployment to was liberty profile in BluemixEclipse tools for deployment to was liberty profile in Bluemix
Eclipse tools for deployment to was liberty profile in BluemixEclipse Day India
 
Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014CloudBees
 
Module 2-web-a11y-steve lee
Module 2-web-a11y-steve leeModule 2-web-a11y-steve lee
Module 2-web-a11y-steve leeSteve Lee
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Phil Leggetter
 
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...Michael Elder
 
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...WASdev Community
 

Semelhante a Advanced UI styling and animations for iOS (20)

Animation in iOS
Animation in iOSAnimation in iOS
Animation in iOS
 
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
 
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
 
Custom Swift Operators: The Good, the Bad and the Ugly
Custom Swift Operators: The Good, the Bad and the UglyCustom Swift Operators: The Good, the Bad and the Ugly
Custom Swift Operators: The Good, the Bad and the Ugly
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
 
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...
Building GPU-Accelerated Mobile Application Interfaces with Starling and Feat...
 
Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...
 
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
 
Continuous Deployment of your Application - SpringOne Tour Dallas
Continuous Deployment of your Application - SpringOne Tour DallasContinuous Deployment of your Application - SpringOne Tour Dallas
Continuous Deployment of your Application - SpringOne Tour Dallas
 
Adobe MAX 2015 - Giving Flash Professional Another Look
Adobe MAX 2015 - Giving Flash Professional Another LookAdobe MAX 2015 - Giving Flash Professional Another Look
Adobe MAX 2015 - Giving Flash Professional Another Look
 
UX Design at the Speed of Thought
UX Design at the Speed of ThoughtUX Design at the Speed of Thought
UX Design at the Speed of Thought
 
DSpace UI prototype dsember
DSpace UI prototype dsemberDSpace UI prototype dsember
DSpace UI prototype dsember
 
Eclipse tools for deployment to was liberty profile in Bluemix
Eclipse tools for deployment to was liberty profile in BluemixEclipse tools for deployment to was liberty profile in Bluemix
Eclipse tools for deployment to was liberty profile in Bluemix
 
Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014
 
Module 2-web-a11y-steve lee
Module 2-web-a11y-steve leeModule 2-web-a11y-steve lee
Module 2-web-a11y-steve lee
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
 
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...
DBD 2414 - Iterative Web-Based Designer for Software Defined Environments (In...
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
 
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...
AAI-2016 WebSphere Application Server Installation and Maintenance in the Ent...
 
Webinar: "Continuous Delivery with Jenkins"
Webinar: "Continuous Delivery with Jenkins"Webinar: "Continuous Delivery with Jenkins"
Webinar: "Continuous Delivery with Jenkins"
 

Último

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxNadaHaitham1
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 

Último (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 

Advanced UI styling and animations for iOS

  • 1. © 2015 WIRE SWISS GMBH Advanced UI styling and animations for iOS
  • 2. © 2015 WIRE SWISS GMBH AdvancedUIstylingandanimationsforiOS
  • 3. © 2014 WIRE SWISS GMBH About the Author: Mike Gerasymenko • Working on iOS since 2008 (iOS 2.2) • Around 35 apps for the AppStore • With Wire since March 2014
  • 4. © 2014 WIRE SWISS GMBH Disclaimer • A lot of open-source code is used • Not all presented is created at Wire • We love open-source and we do pull requests and share the things we develop • github.com/wearezeta
  • 5. © 2014 WIRE SWISS GMBH Follow-Up on Cristobal’s presentation • Why I brought up this topic? • Bring the Sense of continuity • Broaden-up the insight for those who was interested last time • Give a deep insight on how UI works in Wire • Design is crucial
  • 6. © 2015 WIRE SWISS GMBH Plan • Everything is Custom: • Custom animation’s timings on UIViews and CALayers • Custom styling for the user interface • One More Thing
  • 7. © 2014 WIRE SWISS GMBH Glossary
  • 8. © 2014 WIRE SWISS GMBH Animation timing (easing): functions • Animation is a change of property from initial (A) to end value (B) in given time (t) • How the change is distributed over the time t? • Timing curve (Easing): • Gives animation progress for time • Implementation: • UIView: predefined set of timing curves • CoreAnimation: can be defined as arbitrary Bézier curve that starts in (0, 0) and ends in (1, 1), so two control points can vary
  • 9. © 2014 WIRE SWISS GMBH Animation timing (easing): functions • Animation is a change of property from initial (A) to end value (B) in given time (t) • How the change is distributed over the time t? • Timing curve (Easing): • Gives animation progress for time • Implementation: • UIView: predefined set of timing curves • CoreAnimation: can be defined as arbitrary Bézier curve that starts in (0, 0) and ends in (1, 1), so two control points can vary
  • 10. © 2014 WIRE SWISS GMBH Animation timing (easing): example
  • 11. © 2014 WIRE SWISS GMBH Animation timing (easing): custom timing Why custom timing function is important? Because designers says so Because it looks better and makes the difference How we can use custom timing function with UIView animation? We can’t, it is not supported by the API ?
  • 12. © 2015 WIRE SWISS GMBH Animation timing (easing): Math 101 • Bezier curves are defined as power functions • Exponential functions are the different set of functions • Use «Best Fitting» Bezier curves, would be not equal to expo but close enough • Root mean squared error is as low as 0.00000102 ( ) ( )( )( ) ( ) ( ) tttt dxxfy 1 1 0 2 ∫ −
  • 13. © 2014 WIRE SWISS GMBH The Problem
  • 14. © 2015 WIRE SWISS GMBH Animation timing (easing) • UIView animations do not support custom easing • CoreAnimation API is complicated and bulky • We need to implement the API that would work as UIView, but support passing in the custom easing
  • 15. © 2015 WIRE SWISS GMBH Animation timing (easing): UIView animation 101 • UIViews are using CALayers (.layer from CoreAnimation framework) to display it’s contents • CALayers are using CAAnimation family to do animations • Conclusion: when UIView animation is created the backing animation is CAAnimation anyway • We need to find a way to create CAAnimations like iOS do: 1 [UIView animateWithDuration: timingFunction: animations:^{ 2 view.property = newValue; 3 }] and produce the CAAnimations on the appropriate objects
  • 16. © 2015 WIRE SWISS GMBH Animation timing (easing): Introducing UIView+ExtendedBlockAnimations • Approach: • Swizzle -[CALayer actionForLayer:forKey:] • When animation method is called, call UIView animation block with the same parameters and expect it to create the animations on CALayers • Capture when UIView creates it’s animations • Replace created animations with our own animations that are utilising the custom timing functions
  • 17. © 2014 WIRE SWISS GMBH To The Code
  • 18. © 2015 WIRE SWISS GMBH Animation timing (easing): Preparation Swizzle: 1 SEL originalSelector = @selector(actionForLayer:forKey:); 2 SEL extendedSelector = @selector(WR_actionForLayer:forKey:); 3 4 Method originalMethod = class_getInstanceMethod(self, originalSelector); 5 Method extendedMethod = class_getInstanceMethod(self, extendedSelector); 6 7 method_exchangeImplementations(originalMethod, extendedMethod); Apply: 1 - (id<CAAction>)WR_actionForLayer:(CALayer *)layer forKey:(NSString *)event 2 { 3 ... 4 if (currentContext == BlockAnimationsContext && 5 [supportedProperties containsObject:event]) { 6 7 [savedAnimations addObject:[WRSavedAnimationState savedStateWithLayer:layer 8 keyPath:event]]; 9 10 // no implicit animation (it will be added later) 11 return (id<CAAction>)[NSNull null]; 12 } 13 ... 14 }
  • 19. © 2015 WIRE SWISS GMBH Animation timing (easing): application 1 + (void)wr_animateWithEasing:(RBBEasingFunction)easing 2 duration:(NSTimeInterval)duration 3 delay:(NSTimeInterval)delay 4 animations:(void (^)(void))animations 5 options:(WRExtendedBlockAnimationsOptions)options 6 completion:(void (^)(BOOL finished))completion 7 { 8 RBBTweenAnimation *animation = [[RBBTweenAnimation alloc] init]; // create the template anim 9 animation.easing = easing; 10 ... 11 12 [self wr_animateWithBasicAnimation:animation 13 duration:duration 14 animations:animations 15 options:options 16 completion:completion]; 17 }
  • 20. © 2015 WIRE SWISS GMBH Animation timing (easing): easy as 1-2-3 1 [UIView wr_animateWithEasing:RBBEasingFunctionEaseInExpo duration:0.35 delay:0 animations:^{ 2 // Do animations 3 view.frame = newFrame; 4 view.alpha = 1.0f; 5 view.transform = newTransform; 6 } completion:^(BOOL finished) { 7 // Do completion 8 }];
  • 21. © 2014 WIRE SWISS GMBH
  • 22. © 2014 WIRE SWISS GMBH Animation timing (easing) Grab it at goo.gl/uYItrG
  • 23. © 2014 WIRE SWISS GMBH Questions
  • 24. © 2014 WIRE SWISS GMBH Interface Styling Defining User Interface style
  • 25. © 2014 WIRE SWISS GMBH Interface Styling: What we need? • Ability to define UI element’s style: • Colour • Font • Insets • Any other style-related property • Per element objc-class, class, parent • Ability to tweak style during runtime • Clean stylesheet format
  • 26. © 2014 WIRE SWISS GMBH Interface Styling: Classy! ✓ Ability to define UI element’s style: ✓ Colour ✓ Font ✓ Insets ✓ Any other style-related property ✓ Per element objc-class, class, parent ✓ Ability to tweak style during runtime ✓ Clean stylesheet format
  • 27. © 2014 WIRE SWISS GMBH – http://cloudkite.github.io/Classy/ “Not CSS. Instead of trying to force UIKit to fit CSS syntax, properties, conventions and constructs. Classy is a stylesheet system built from the ground up to work in harmony with UIKit. It borrows the best ideas from CSS and introduces new syntax, conventions and constructs where appropriate.” Interface Styling: Classy!
  • 28. © 2014 WIRE SWISS GMBH Interface Styling: Classy integration • Steps to integrate Classy: • Grab framework via • CocoaPods: pod 'Classy', '~> 0.2.4’ • Carthage: github "cloudkite/Classy" • Create stylesheet • Insert minimal initialisation code • Profit!
  • 29. © 2014 WIRE SWISS GMBH Interface Styling: Classy stylesheet 1 @import "colors.cas"; 2 3 $accentColor = #acacac; 4 5 // Supports custom UIView subclasses 6 WireView { 7 background-color: $accentColor; 8 title-insets: 5, 10, 5, 10; 9 > UIProgressView.tinted { 10 progress-tint-color: rgb(200, 155, 110, 0.6); 11 track-tint-color: yellow; 12 } 13 } 14 15 ^UIButton.warning, UIView.warning ^UIButton { 16 title-color[state:highlighted]: #e3e3e3; 27 }
  • 30. © 2014 WIRE SWISS GMBH Interface Styling: Classy selectors • Selectors: • Runtime class name • cas_styleClass class • Containment • Property of • Selectors can be mixed
  • 31. © 2014 WIRE SWISS GMBH Interface Styling: Classy properties • Properties supported: • Any system or user-defined • Property types supported: • UIColor • UIFont • UIEdgeInsets • Any custom property
  • 32. © 2014 WIRE SWISS GMBH Interface Styling: Classy in the nutshell + Classy = Un-Styled UI Different themes or
  • 33. © 2014 WIRE SWISS GMBH Interface Styling: Classy testing • Selectors and properties • Covered by unit and integration tests • We commit to Classy with PRs; adding more test coverage to the product
  • 34. © 2014 WIRE SWISS GMBH One more thing
  • 35. © 2014 WIRE SWISS GMBH Interface Styling: Classy live editing • Classy can observe the filesystem changes on the stylesheet and re-apply the updates live • Knowing that we added the WebDAV client in the application’s development builds • Now design people can tweak certain properties realtime using the iPhone, dev build and their mac with a text editor
  • 36. © 2014 WIRE SWISS GMBH Questions
  • 37. © 2014 WIRE SWISS GMBH
  • 38. © 2014 WIRE SWISS GMBH Regards to my fellow colleagues Cristobal Castilla Jacob Persson Vjacheslav Volodko Alan Duric Marke Saaremets Natalia Dorozala
  • 39. © 2014 WIRE SWISS GMBH Contact data Mike Gerasymenko mihail@gerasimenko.me (find me on Wire using this email) mike@wire.com
  • 40. © 2014 WIRE SWISS GMBH