upbeat.it

by Cesare Rocchi

Detecting Screen Brightness in iOS

by Cesare Rocchi

I am a huge fan of small libraries that do just one thing but well. Sure you can detect when screen brightness changes by listening to the UIScreenBrightnessDidChangeNotification, but ASCScreenBrightnessDetector by aschndr is the right sugar on top of that. All you need is to create an instance, set a delegate and implement the - (void)screenBrightnessDidChange:(CGFloat)brightness; method, like this.

If you are already using Cocoapods, including it is a breeze.

I am gonna use it in Neater.