I have an iPhone app for photographic purposes (kind of a lightbox). This app needs as much brightness as possible. Is there a way to change the screen brightness programmat
Here's a Swift answer to this question.
import UIKit
extension UIScreen
{
static func setMainBrightness(brightness: CGFloat)
{
guard (0...1).contains(brightness) else
{
print("Attempt to set the screen brightness to an invalid value: \(brightness) should be between 0 and 1 inclusive.")
return
}
self.main.brightness = brightness
}
}
Call it by using:
UIScreen.setMainBrightness(0.5)
Or ignore my extension (which I just wrote to illustrate the limits) and just call:
UIScreen.main.brightness = 0.5