How to turn off Auto-Brightness programmatically?

南楼画角 提交于 2019-12-01 07:48:31

问题


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?


回答1:


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.




回答2:


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."




回答3:


But you can check brightness periodically and take it to the level you wish when your application is running if you really want it.




回答4:


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)

https://discussions.apple.com/thread/2009141?tstart=0



来源:https://stackoverflow.com/questions/14782700/how-to-turn-off-auto-brightness-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!