How to change screen brightness programmatically in iOS?

iOSApps/ApplicationsMobile Development

To change the brightness of the screen we have to use the brightness property of the screen, This property is only supported on the main screen. The value of this property should be a number between 0.0 and 1.0, inclusive.

Brightness changes made by an app remain in effect until the device is locked, regardless of whether the app is closed. The system brightness (which the user can set in Settings or Control Center) is restored the next time the display is turned on.

It’s an instance property, To implement this in your iOS Application (any application) add below line in viewDidLoad method to see the effect.

UIScreen.main.brightness = 0.1 // (0-1)
Updated on 30-Aug-2019 11:28:09