Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Adopting Dark Mode

Swift India
September 14, 2019

Adopting Dark Mode

Presentation Video: https://www.youtube.com/watch?v=fwBc-jEky2E

Overview of the new API added to aid implementation of API on iOS 13. We'll cover mainly the dynamic UIColor objects, how to deal with the compatibility on older iOS versions & some common issues & gotchas.

Speaker: Nishant Desai, iOS Engineer at PSPDFKit
https://twitter.com/nish_desai

Presented at Swift Mumbai Chapter X Meetup hosted by WeWork Goregaon
https://www.meetup.com/Swift-Mumbai/events/262515637/

Swift India

September 14, 2019
Tweet

More Decks by Swift India

Other Decks in Programming

Transcript

  1. Dark Mode… why? • System level support. • Easier on

    the eyes. • Kind on battery. • …. it looks amazing!
  2. New User Interface Traits • UIAccessibilityContrast - Constrast. • UILegibilityWeight

    - Font weight (bold text value). • UIUserInterfaceStyle - light / dark mode. • UIUserInterfaceLevel - Visual level.
  3. Enforcing user interface style • UIUserInterfaceStyle in Info.plist. • Set

    `overrideUserInterfaceStyle` to have a specific style for view elements (UIView, UIViewController). • Use overrideTraitCollection to override specific traits. • Only supported on UIViewController and UIPresentationController.
  4. Resolving Dynamic Colors • Dynamic colors are only supported by

    UIKit. • Core Graphics uses static color. • Methods to resolve colors:
  5. UI Element Colors • Dynamic colors which adapt to all

    system appearances. • Colors defined for background color usage, label, separators and fill. • New primary system colors.
  6. Dynamic Images • Asset Catalog supports adding dynamic images. •

    Use imageAsset property to resolve dynamic images. • Use UIImageView trait collections. • Use UIImage.withTintColor(_:) to create a dynamically tinting image.
  7. Backwards Compatibility • All the API discussed are only available

    iOS 13 and above. • Consider using extensions and categories as wrappers around them.