xcode 让用户在应用程序中调整亮度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11615078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Letting user adjust brightness in application
提问by Sam B
I am making a clock app and I wanted to know how can I check what the current brightness level is set to and how can i adjust brightness in my application in xcode 4 with a UISlider instead of telling the user to go to their iphone/ipad setting app and adjust the brightness there? I can't find any code/api for it.
我正在制作一个时钟应用程序,我想知道如何检查当前亮度级别的设置以及如何使用 UISlider 在 xcode 4 中调整我的应用程序中的亮度,而不是告诉用户转到他们的 iphone/ipad设置应用程序并在那里调整亮度?我找不到任何代码/api。
I have seen quite a few clock apps in appstore where the user can adjust the brightness of the display just by moving the finger up or down.
我在 appstore 看到不少时钟应用,用户只需上下移动手指就可以调整显示屏的亮度。
回答by jrturton
You're looking for the brightness property of UIScreen.
Sample code:
示例代码:
[UIScreen mainScreen].brightness = 0.5;
Available in iOS 5.0 and later.
在 iOS 5.0 及更高版本中可用。