SlideShare a Scribd company logo
Handling Dark Mode in
Android and iOS
Mike Wolfson
@mikewolfson
Handling Dark Mode in
Android and iOS
Mike Wolfson
@mikewolfson
What is
Dark
Mode?
?
“ (Material) A low-light UI
that uses majority of dark
surfaces and uses color as
an accent throughout
4
https://material.io/design/color/dark-theme.html
@mikewolfson
Material
DarkMode
Place your screenshot here
5
A low-light UI that uses
majority of dark
surfaces and uses
color as an accent
throughout
@mikewolfson
“
(Apple HIG) In Dark Mode, the system
adopts a darker color palette for all
windows, views, menus, and controls.
The system also uses more vibrancy
to make foreground content stand out
against the darker backgrounds.
6
https://developer.apple.com/design/human-interface-guidelines/ios/
visual-design/dark-mode/
@mikewolfson
Place your screenshot here
7
Apple
HIG
Dark
Mode
(Apple HIG) In Dark
Mode, the system
adopts a darker color
palette for all windows,
views, menus, and
controls. The system
also uses more vibrancy
to make foreground
content stand out
against the darker
backgrounds.
@mikewolfson
Why Use Dark Mode?
Better For
Your Health
Native OS
Support
Battery
Savings
8
Accessibility Reduced
Eye Strain
It is Stylish!
@mikewolfson
Behavior
Android
User selects Mode:
○ Dark
○ Light
○ System
9
iOS
People can choose Dark
Mode as their default
interface style, and they
can use Settings to
make their devices
automatically switch to
Dark Mode when
ambient light is low.
@mikewolfson
Dark Mode
Principles
(Material)
*
Principles
11
Enhance accessibility
Accommodate regular
dark theme users (such
as those with low vision),
by meeting accessibility
color contrast
standards.
Conserve energy
In products that require
efficiency (such as
devices with OLED
screens), conserve
battery life by reducing
the use of light pixels.
Darken with grey
Use dark grey – rather than
black – to express elevation and
space in an environment with a
wider range of depth.
Color with accents
Apply limited color accents in
dark theme UIs, so the majority
of space is dedicated to dark
surfaces.
@mikewolfson
Conserve Energy
“In products that require
efficiency (such as devices with
OLED screens), conserve battery
life by reducing the use of light
pixels.”
12
@mikewolfson
Darken With Grey
“Use dark grey – rather than
black – to express elevation and
space in an environment with a
wider range of depth.”
13
@mikewolfson
14
Shadow Grows
as Material gains
Elevation
@mikewolfson
15
Dark Mode:
As a surface
raises in
elevation, it
becomes lighter
in color
16
@mikewolfson
Enhance
Accessibility
“Accommodate regular dark
theme users (such as those with
low vision), by meeting
accessibility color contrast
standards.”
17
@mikewolfson
Minimum Contrast Requirements
Ensure you are meeting the minimum standards, to
ensure your content is legible:
WCAG - 4.5 : 1
HIG (WGAC AAA) - 7 : 1
Material - 15.8 : 1
* The material ratio is large to account
for the changes in surface color due to
elevation changes 18
Contrast - Readability
19
https://www.maketecheasier.com/are-dark-themes-better-for-eyes-battery/
20
Contrast
@mikewolfson
Soft Contrast is more readible
21
https://www.maketecheasier.com/are-dark-themes-better-for-eyes-battery/
22
CONTRAST
@mikewolfson
23
CONTRAST
Avoid Vibration!
24
CONTRAST
Use Desaturated
Colors
25
CONTRAST CONTRAST CONTRAST
@mikewolfson
Color With
Accents
“Apply limited color accents in
dark theme UIs, so the majority of
space is dedicated to dark
surfaces.”
26
@mikewolfson
What about iOS?
iOS 13 introduced dark mode -few months ago
macOS 10.14 introduced it previously
27
@mikewolfson
Similarities
Users will increasingly
expect your app to
support dark mode
○ iOS 13 was released in September 2019. Adoption will
be rapid. Potentially as high as 75% by EOY if history
holds. (Not yet an App Store requirement.)
○ Android Q released in August 2019.
○ iOS will not support force dark.
29
Semantic color
○ Both platforms lean into thinking about
color semantically.
○ What is the purpose of a color rather
than specific hex values.
30
@mikewolfson
Both platforms
provide support for
semantic colors
○ iOS with UIKit system colors
○ Android with Material Components and
AppCompat
○ Both platforms recommend using
system colors when possible.
31
@mikewolfson
3
32
Semantic colors go
beyond light and
dark mode
○ Color is determined by more variables
the system’s dark/light appearance.
○ Elevation and a11y appearance settings
also influence system colors values.
Color
Whitelight
dark
Black
Elevation 1
Elevation 0
Dark Gray
@mikewolfson
Support for custom colors
○ Both platform support custom colors
which can have differing light and dark
hex and alpha values.
○ Single hex can also be used across
dark and light modes. Such as for
brand colors.
33
@mikewolfson
Depth
○ Both platforms provide direction on how
depth should be visually communicated.
○ Depth visually differs between dark and
light mode.
34
@mikewolfson
35
Differences
App vs OS
appearance
○ Google suggests allowing users to
override system level appearance
setting
○ Apple is leaning into 3rd party apps
looking like and feeling like part of the
the platform
37
@mikewolfson
iOS Materials
○ Apple introduced materials for iOS 13.
○ Materials have light and dark mode
variants.
○ Differs from Material Design by using
translucency
38
“… materials (or blur
effects) that create a
translucent effect you can
use to evoke a sense of
depth. The effect of a
material lets views and
controls hint at background
content without distracting
from foreground content.
...”
- iOS HIG
@mikewolfson
39
Dark
Light
40
Dark
Variant icons
○ Apple puts emphasis on stroke
width of icons differentiating
between dark and light modes.
Increasing the width for dark mode.
○ Apple has its own icon library. SF
symbols supports variable stroke
width out of the box.
41
@mikewolfson
42
≈
Thinking cross platform
○ Valuable to find a cross
platform way to thinking about
color and depth.
○ Thinking semantically in a way
which translates to both
Android and iOS UI systems.
43
@mikewolfson
Implementation
Example
(Android)
1
Force Dark Mode
45
<style name="Base.Theme.DesignDemo"
parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:forceDarkAllowed"
tools:targetApi="q">true</item>
System calculates changes and applies them
automatically at run-time.
● Only Works With Q
● No control - system makes all choices
@mikewolfson
Force Dark Mode
46
<LinearLayout
...
android:forceDarkAllowed="true"
...>
Can also apply it to just a single Layout
@mikewolfson
Force Dark Mode - results
47
Force Dark Mode - results
48
Implement DayNight Theme
49
Step 1: Use the Material Themes and Styles Correctly
<style name="Base.Theme.DesignDemo"
parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
...
</style>
Step 2: Leverage existing DayNight theme
- Support back to API 14
@mikewolfson
Use Night Qualifier for custom colors
50
Implement DayNight Theme
51
Step 1: Use the Material Themes and Styles Correctly
@mikewolfson
Implement DayNight Theme
52
Step 1: Use the Material Themes and Styles Correctly
app:chipStrokeColor="@color/black"
app:chipStrokeColor="@color/color_on_primary"
app:chipStrokeColor="?attr/colorOnPrimary"
NO!
NO!
YES
Make sure to use the Material defined attributes
Provide Desaturated Colors for Night Mode
53
@mikewolfson
Android Studio Has a tool to modify colors
54
Hint:
@mikewolfson
Material Semantic Colors
55
colorPrimary
colorPrimaryDark
colorOnPrimary
colorSurface
colorOnSurface
colorSurface
(with elevation)
colorSecondary
colorOnSecondary
colorError
colorOnError
Android Resources
https://developer.android.com/preview/features/darktheme
https://material.io/design/color/dark-theme.html
https://github.com/googlesamples/android-DarkTheme
https://twitter.com/chrisbanes/status/1126607526689005568
56
@mikewolfson
Implementation
Example
(iOS)
2
Implementing Dark Mode
58
HIG recommends using system color’s as much as
possible.
System Colors Cont...
59
Apple also provides system defined semantic naming for some UI
elements
@mikewolfson
How to implement Dark mode with
your own custom colors
Two Approaches:
● Asset Catalogue
● UIColor+Extension
60
@mikewolfson
Custom Colors: Asset Catalogue
61
You can define custom colors in an app’s
Assets.xcassets folder.
Asset Catalogue cont.
62
● Once you have defined a color in an asset
catalogue you can refer to it by name when
initiating a UIColor via the “UIColor(named:
‘MyCustomColor’) signature.
● Asset Catalogue colors can be used in Xibs
● iOS applications can have many Asset
catalogues if you want to make one just for
colors.
● Asset Catalogue colors can also define
accessibility variations(High Contrast).
@mikewolfson
Asset Catalogue cont.
63
Benefits of Asset Catalogued Colors:
● Named colors are easy to
comprehend, and visualize
● ‘No Code’ implementation allows
anyone to update or manage.
● Can be used in Storyboards and
XIb files (iOS 11 and above).
● The Apple ‘Recommended’ Way
Drawbacks:
● Uses an xcode document
editor and isn’t done
programmatically.
● Future updates to color’s can
have negative consequences
since Custom colors aren’t
searchable in xibs.
@mikewolfson
Custom Colors: UIColor Extension
64
If you hate apple’s interface builders you can define
colors in a UIColor extension
extension UIColor {
static var batmanLogo: UIColor {
if #available(iOS 13, *) {
return UIColor { (traitCollection: UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return BatmanUI.batmanYellow
} else {
return BatmanUI.batmanBlack
}
}
} else {
return BatmanUI.batmanBlack
}
}
}
UIColor Extension - use switch for a11y
65
static var batmanLogo: UIColor {
if #available(iOS 13, *) {
return UIColor { (traitCollection: UITraitCollection) -> UIColor in
switch(traitCollection.userInterfaceStyle,
traitCollection.accessibilityContrast)
{
case (.dark, .high): return BatmanUI.batmanRed
case (.dark, _): return BatmanUI.batmanYellow
case (_, .high): return BatmanUI.batmanRed
default: return BatmanUI.batmanBlack
}
}
} else {
return BatmanUI.batmanBlack
}
}
UIColor Extension cont.
66
Benefits:
● Full Control
● Easy to manage
multiple color palettes.
● UIColor autocompletion
● Easily Searchable
Drawbacks
● Overhead.
● Can’t reference
custom color’s in Xibs
● #available
● Less future proof.
@mikewolfson
Slide Credits
Special thanks to all the people who
made and released these awesome
resources for free:
○ Presentation template by
SlidesCarnival - Cymbeline
○ Photographs by Unsplash
67
@mikewolfson
Thank You!
Mike Wolfson
@mikewolfson
https://tiny.cc/oredev_darkmode

More Related Content

Similar to Handling Dark Mode on Android and iOS

Open GL for Mobile UI
Open GL for Mobile UIOpen GL for Mobile UI
Open GL for Mobile UIAnil N
 
Presentation on Android application
Presentation on Android applicationPresentation on Android application
Presentation on Android applicationAtibur Rahman
 
ISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art, LLC
 
HashiCorp Brand Guide
HashiCorp Brand GuideHashiCorp Brand Guide
HashiCorp Brand GuideHashiCorp
 
Class #1: Blocks and Vocabulary
Class #1: Blocks and VocabularyClass #1: Blocks and Vocabulary
Class #1: Blocks and VocabularyAngela DeHart
 
Application Development with Pharo
Application Development with PharoApplication Development with Pharo
Application Development with PharoESUG
 
Абрамович Максим, "Rad studio xe4"
Абрамович Максим, "Rad studio xe4"Абрамович Максим, "Rad studio xe4"
Абрамович Максим, "Rad studio xe4"EPAM Systems
 
Ipadcommunicationapps 110921070532-phpapp01
Ipadcommunicationapps 110921070532-phpapp01Ipadcommunicationapps 110921070532-phpapp01
Ipadcommunicationapps 110921070532-phpapp01Rob LeFebvre
 
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023Pedro Vicente
 
Designing for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaDesigning for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaMobileNepal
 
iOS 7.1 accessibility for developers
iOS 7.1 accessibility for developersiOS 7.1 accessibility for developers
iOS 7.1 accessibility for developersTed Drake
 
Transfer Learning: An overview
Transfer Learning: An overviewTransfer Learning: An overview
Transfer Learning: An overviewjins0618
 
Eskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleEskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleAngelo Gino Varrati
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 IntroductionSperasoft
 
Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012Jan Kroon
 
iPads in the Early Years Classroom
iPads in the Early Years ClassroomiPads in the Early Years Classroom
iPads in the Early Years Classroomkarlaholt
 
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...Joseph Labrecque
 
What's new in Android Lollipop
What's new in Android LollipopWhat's new in Android Lollipop
What's new in Android LollipopAbdellah SELASSI
 
Material Design - Høgskolen Ringerike 2017
Material Design - Høgskolen Ringerike 2017Material Design - Høgskolen Ringerike 2017
Material Design - Høgskolen Ringerike 2017Konstantin Loginov
 

Similar to Handling Dark Mode on Android and iOS (20)

Open GL for Mobile UI
Open GL for Mobile UIOpen GL for Mobile UI
Open GL for Mobile UI
 
Presentation on Android application
Presentation on Android applicationPresentation on Android application
Presentation on Android application
 
ISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin Multiplatform
 
HashiCorp Brand Guide
HashiCorp Brand GuideHashiCorp Brand Guide
HashiCorp Brand Guide
 
Class #1: Blocks and Vocabulary
Class #1: Blocks and VocabularyClass #1: Blocks and Vocabulary
Class #1: Blocks and Vocabulary
 
Application Development with Pharo
Application Development with PharoApplication Development with Pharo
Application Development with Pharo
 
Абрамович Максим, "Rad studio xe4"
Абрамович Максим, "Rad studio xe4"Абрамович Максим, "Rad studio xe4"
Абрамович Максим, "Rad studio xe4"
 
Ipadcommunicationapps 110921070532-phpapp01
Ipadcommunicationapps 110921070532-phpapp01Ipadcommunicationapps 110921070532-phpapp01
Ipadcommunicationapps 110921070532-phpapp01
 
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
 
Designing for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaDesigning for Android - Anjan Shrestha
Designing for Android - Anjan Shrestha
 
iOS 7.1 accessibility for developers
iOS 7.1 accessibility for developersiOS 7.1 accessibility for developers
iOS 7.1 accessibility for developers
 
Transfer Learning: An overview
Transfer Learning: An overviewTransfer Learning: An overview
Transfer Learning: An overview
 
Eskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleEskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo Digitale
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012
 
Mobile world
Mobile worldMobile world
Mobile world
 
iPads in the Early Years Classroom
iPads in the Early Years ClassroomiPads in the Early Years Classroom
iPads in the Early Years Classroom
 
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
 
What's new in Android Lollipop
What's new in Android LollipopWhat's new in Android Lollipop
What's new in Android Lollipop
 
Material Design - Høgskolen Ringerike 2017
Material Design - Høgskolen Ringerike 2017Material Design - Høgskolen Ringerike 2017
Material Design - Høgskolen Ringerike 2017
 

More from Mike Wolfson

Effective Remote Teamwork
Effective Remote TeamworkEffective Remote Teamwork
Effective Remote TeamworkMike Wolfson
 
The Haggadah Story For Young Children
The Haggadah Story For Young ChildrenThe Haggadah Story For Young Children
The Haggadah Story For Young ChildrenMike Wolfson
 
Move Into Motion Layout
Move Into Motion LayoutMove Into Motion Layout
Move Into Motion LayoutMike Wolfson
 
Human + Machine Learning : Oredev Human Centered Machine Learning
Human + Machine Learning : Oredev Human Centered Machine LearningHuman + Machine Learning : Oredev Human Centered Machine Learning
Human + Machine Learning : Oredev Human Centered Machine LearningMike Wolfson
 
Human + Machine Learning
Human + Machine LearningHuman + Machine Learning
Human + Machine LearningMike Wolfson
 
Effective Remote Teamwork DevFest Minnesota 2018
Effective Remote Teamwork DevFest Minnesota 2018Effective Remote Teamwork DevFest Minnesota 2018
Effective Remote Teamwork DevFest Minnesota 2018Mike Wolfson
 
Introduction To Android - Short
Introduction To Android - ShortIntroduction To Android - Short
Introduction To Android - ShortMike Wolfson
 
Introduction To Android - Long
Introduction To Android - LongIntroduction To Android - Long
Introduction To Android - LongMike Wolfson
 
Mastering Material Motion
Mastering Material MotionMastering Material Motion
Mastering Material MotionMike Wolfson
 
Material Design basics for Android and the Web
Material Design basics for Android and the WebMaterial Design basics for Android and the Web
Material Design basics for Android and the WebMike Wolfson
 
Android Developer Tools Essentials - Oscon 14
Android Developer Tools Essentials - Oscon 14Android Developer Tools Essentials - Oscon 14
Android Developer Tools Essentials - Oscon 14Mike Wolfson
 
Android Developer Tools Essentials
Android Developer Tools EssentialsAndroid Developer Tools Essentials
Android Developer Tools EssentialsMike Wolfson
 
AnDevCon IV - Android Bootcamp
AnDevCon IV - Android BootcampAnDevCon IV - Android Bootcamp
AnDevCon IV - Android BootcampMike Wolfson
 
AnDevCon IV - Advanced Android Developer Tools
AnDevCon IV - Advanced Android Developer ToolsAnDevCon IV - Advanced Android Developer Tools
AnDevCon IV - Advanced Android Developer ToolsMike Wolfson
 
AnDevCon IV - Intro to Android Developer Tools
AnDevCon IV - Intro to Android Developer ToolsAnDevCon IV - Intro to Android Developer Tools
AnDevCon IV - Intro to Android Developer ToolsMike Wolfson
 
Android For Java Developers
Android For Java DevelopersAndroid For Java Developers
Android For Java DevelopersMike Wolfson
 
Intro to Android for the iOS Fan
Intro to Android for the iOS FanIntro to Android for the iOS Fan
Intro to Android for the iOS FanMike Wolfson
 
Mobile tech is saving the world
Mobile tech is saving the worldMobile tech is saving the world
Mobile tech is saving the worldMike Wolfson
 
Android Development Tools Overview
Android Development Tools OverviewAndroid Development Tools Overview
Android Development Tools OverviewMike Wolfson
 

More from Mike Wolfson (20)

Effective Remote Teamwork
Effective Remote TeamworkEffective Remote Teamwork
Effective Remote Teamwork
 
The Haggadah Story For Young Children
The Haggadah Story For Young ChildrenThe Haggadah Story For Young Children
The Haggadah Story For Young Children
 
Move Into Motion Layout
Move Into Motion LayoutMove Into Motion Layout
Move Into Motion Layout
 
Human + Machine Learning : Oredev Human Centered Machine Learning
Human + Machine Learning : Oredev Human Centered Machine LearningHuman + Machine Learning : Oredev Human Centered Machine Learning
Human + Machine Learning : Oredev Human Centered Machine Learning
 
Human + Machine Learning
Human + Machine LearningHuman + Machine Learning
Human + Machine Learning
 
Effective Remote Teamwork DevFest Minnesota 2018
Effective Remote Teamwork DevFest Minnesota 2018Effective Remote Teamwork DevFest Minnesota 2018
Effective Remote Teamwork DevFest Minnesota 2018
 
Introduction To Android - Short
Introduction To Android - ShortIntroduction To Android - Short
Introduction To Android - Short
 
Introduction To Android - Long
Introduction To Android - LongIntroduction To Android - Long
Introduction To Android - Long
 
Mastering Material Motion
Mastering Material MotionMastering Material Motion
Mastering Material Motion
 
Material Design basics for Android and the Web
Material Design basics for Android and the WebMaterial Design basics for Android and the Web
Material Design basics for Android and the Web
 
Android Developer Tools Essentials - Oscon 14
Android Developer Tools Essentials - Oscon 14Android Developer Tools Essentials - Oscon 14
Android Developer Tools Essentials - Oscon 14
 
Android Developer Tools Essentials
Android Developer Tools EssentialsAndroid Developer Tools Essentials
Android Developer Tools Essentials
 
AnDevCon IV - Android Bootcamp
AnDevCon IV - Android BootcampAnDevCon IV - Android Bootcamp
AnDevCon IV - Android Bootcamp
 
AnDevCon IV - Advanced Android Developer Tools
AnDevCon IV - Advanced Android Developer ToolsAnDevCon IV - Advanced Android Developer Tools
AnDevCon IV - Advanced Android Developer Tools
 
AnDevCon IV - Intro to Android Developer Tools
AnDevCon IV - Intro to Android Developer ToolsAnDevCon IV - Intro to Android Developer Tools
AnDevCon IV - Intro to Android Developer Tools
 
Phxmobilefest
PhxmobilefestPhxmobilefest
Phxmobilefest
 
Android For Java Developers
Android For Java DevelopersAndroid For Java Developers
Android For Java Developers
 
Intro to Android for the iOS Fan
Intro to Android for the iOS FanIntro to Android for the iOS Fan
Intro to Android for the iOS Fan
 
Mobile tech is saving the world
Mobile tech is saving the worldMobile tech is saving the world
Mobile tech is saving the world
 
Android Development Tools Overview
Android Development Tools OverviewAndroid Development Tools Overview
Android Development Tools Overview
 

Handling Dark Mode on Android and iOS