I was wondering if there is a method to toggle the "Auto-Brightness" option to the OFF position on iOS devices and if so, what is it?
-
1If there wasn't, the Settings app couldn't do it. So yes there is. – Feb 08 '13 at 23:00
-
1@H2CO3 i dont think this was a yes/no question – Alex Gordon Feb 08 '13 at 23:01
-
@Artem: when I wrote that comment, it was. Now it isn't. – Feb 08 '13 at 23:02
-
@АртёмЦарионов No it most certainly was not. I apologize for the confusion. – David Feb 08 '13 at 23:03
-
@H2CO3 Do you happen to know where I can access such method? Any specific API or framework? – David Feb 08 '13 at 23:04
-
Oh, and before someone starts the argument: I didn't downvote this. I'm too tired for voting. – Feb 08 '13 at 23:04
-
@David Honestly, I don't have the slightest idea. However, you can try class-dumping the Preferences app and/or SpringBoard and/or IOKit, and try to figure out where it is. Reflexive runtime introspection may also be helpful. – Feb 08 '13 at 23:05
-
@David Actually, it's public after all. – Feb 08 '13 at 23:11
-
@David `[UIScreen mainScreen].wantsSoftwareDimming = NO;` – Feb 08 '13 at 23:11
-
@H2CO3 It appears that it is NO by default. The setting is still toggled to ON. – David Feb 08 '13 at 23:14
-
@H2CO3 `wantsSoftwareDimming` has nothing to do with the question. – Sven Feb 09 '13 at 00:47
5 Answers
Brightness can be adjusted when you are inside the app and it is available inside the UIScreen class -
Here's the documentation - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScreen_Class/Reference/UIScreen.html#//apple_ref/occ/instp/UIScreen/brightness
But Apple's official public APIs do not allow an iOS app to access General settings in the Settings app. So you will not be able to change the toggle button inside the settings app.

- 14,555
- 31
- 86
- 125
I can't speak with any authority (can't prove a negative, etc.), but this doesn't seem like a setting that Apple would give 3rd party apps the ability to modify. Sure, Settings.app modifies it, but that doesn't mean there's public API to do it. Since there's no jailbreak
tag on this post, I'm gonna go ahead and assume that the asker is asking about public API. I'm gonna go with "you can't."

- 29,581
- 5
- 84
- 147
-
You're careful since you know that I tend to downvote "this is impossible!!!"-posts that don't have a disclaimer. Good practice! – Feb 08 '13 at 23:09
-
-
Objective-C
[[UIScreen mainScreen] setBrightness:1.0];
is the way to go. Yes you can do it programatically. Just pass the value between 0.0 to 1.0 and you can do it. It is valid according to apple and you won't face any problem.
Swift 3+
UIScreen.main.brightness = CGFloat(1.0)
But you can check brightness periodically and take it to the level you wish when your application is running if you really want it.

- 2,096
- 3
- 23
- 40
-
Should be done by listening to `brightnessDidChangeNotification` instead. – meaning-matters Jun 07 '19 at 12:11
-
This must be the way to do it @meaning-matters I did not know there was such notification at that time. – Hope Jun 12 '19 at 06:42
-
Based on Hope's answer, for those that would like to be notified if the screen automatically changes brightness:
func trackBrightness() {
// Track brightness changes
NotificationCenter.default.addObserver(self, selector: #selector(brightnessDidChange), name: UIScreen.brightnessDidChangeNotification, object: nil)
}
@objc func brightnessDidChange() {
let newBrightness = UIScreen.main.brightness
// Do something
}

- 330
- 3
- 13