Night-Mode For Your iOS App

Jan 15, 2018

Night-Mode or Dark-Mode has been a favorite feature to request by users for all kinds of apps. The reason why is obvious. You use your phone in all kinds of situations day and night, and during the night your eyes are accustomed to less light. Looking at a glaring smartphone display can be very jarring and you might have to turn down the display brightness. But that’s not a good solution. Everything on the display just becomes more difficult to make out. With a Night-Mode or Dark-Mode feature however the color of the text and the background sort of becomes inverted and it’s much easier on the eye at night.

Since there is no dedicated night-mode setting in iOS (Android may have that), app makers reside to all kinds of techniques to switch the mode between day and night automatically. A method I often see is using the ambient light sensor. This method however can be very annoying in situations where it’s not light nor dark and often apps switch back and forth multiple times. When I added this feature to Instacast, I wanted to go a different route. I wanted Instacast to switch only 2 times a day, in the morning and in the evening. So, I came up with what I think was a unique method at the time.

Instacast is not measuring the actual light in the room. Instead it asks for your broad location data and depending on your actual location on the planet, it calculates when the sun is setting or rising approximately. Now you might say, that querying the location and triggering GPS and thus draining the battery only for switching user interface colors is wasteful, and you’re right. That’s why Instacast is only asking for your approximate location. This location is already stored by the phone when it is connected to a cell tower, so only already stored data is passed to the app. This way no actual sensor is fired at that time. After all, for the calculation of the sun angle, it doesn’t really matter if your 100 kilometres here or there. Also, please don’t look at the sun and wait for Instacast to switch the night mode setting exactly on time. The actual calculation is only an approximation. It does not account for terrain height or other physical circumstances, like the earth not really being sphere, but a potato.

So far this method was a huge success. Nobody ever wrote in and complained about it being unreliable or false. I’ve put the daylight calculator on Github if you like to use it in your app.

Jan 19, 2023
How I Ran My Own Mastodon Server in 10 Minutes

Apr 01, 2019
MacBook Pro (eGPU) vs Hackintosh GPU

Jan 12, 2019
My New Silent, Small Hackintosh for 600 EUR

Nov 22, 2018
Instacast is Now Free and Open Source

Sep 12, 2018
What makes a Mac Pro a Mac Pro

Jul 14, 2018
Why you Should Build a Hackintosh

Apr 16, 2018
Why the Blackmagic Pocket Cinema Camera Is Not a Good Vlogging Cam

Apr 09, 2018
ProRes RAW is Here

Apr 03, 2018
Is the Nokia Steel HR Smart Watch an Apple Watch Killer?

Mar 04, 2018
Workaround for Buggy DNG Handling in macOS

Mar 03, 2018
Colorcast 0.5 Adds Support for Cinema DNG, Anamorphic De-Squeeze and Slow Motion

Feb 06, 2018
Open-Source Objective-C API for Magic Lantern

Feb 06, 2018
Colorcast v0.4 Includes RAW Engine And Supports Magic Lantern

Jan 25, 2018
Thoughts on the DJI Mavic Air

Jan 24, 2018
Why I bought a Sony Alpha 7 Mark II in 2018

Jan 18, 2018
Using Metal Performance Shaders with Core Image

Jan 15, 2018
Night-Mode For Your iOS App

Jan 15, 2018
What’s Color Grading and Why You Want That

Jan 09, 2018
My Review of

Dec 27, 2017
Everything That's Wrong with Hackintosh

Dec 21, 2017
Colorcast Alpha v0.3 Available

Dec 19, 2017
RX Vega 64 Hackintosh for High-End Video Work

Sep 07, 2017
Colorcast Alpha v0.2 Available

Aug 31, 2017
First Alpha Version of Colorcast Available

Jun 01, 2015
Vemedio Product Development Has Been Discontinued

Apr 16, 2015
Audio Books vs. Podcasts

Mar 21, 2015
Rejected for Weak Linked Frameworks

Mar 19, 2015
Ideas for A Better App Store

Mar 05, 2015
Auto-Layout works