Implementing Dark Mode in iOS 13

Managing Colors:

Prafulla Singh
2 min readAug 18, 2019

System Colors, with dark mode feature, Apple has introduced some more default colors in UIColor. With these colors, your app can automatically support dark mode and high contrast modes.

let label = UILabel()
label.textColor = UIColor.secondaryLabel
label.textColor = UIColor.systemRed
label.textColor = UIColor.systemFill
//etc

Custom Colors, if available system colors not enough, you can add your own color variants in Assets.xcassets. xcassets provide three types of appearance Any, Dark, and Light. You can set multiple colors of xcassets color entity based on appearance.

Managing Images:

Template rendering, If you are using templet image with tint than its pretty much same as changing the color of a label or view.

let imageView = UIImageView()imageView.image = UIImage(named: "My Image")?.withRenderingMode(.alwaysTemplate).withTintColor(UIColor.systemRed)

Or if you don’t want to write withRenderingMode(.alwaysTemplate) than in xcassets you can directly set default image behavior as follows:

--

--

Prafulla Singh
Prafulla Singh

No responses yet