How would I program the ability to change brightness in-app? I know that its possible as I have seen at least three apps that can do it. This would be very useful for my app. I know that it's only possible in iOS 5 with the UIScreen Class, but I have no idea how to program it. Please help me!
相关问题
- what is the difference between bounded and unbound
- didSelectViewController method not being called (w
- ios5 background management different from ios4?
- CoreBluetooth - Can connectPeripheral be called mu
- reloadData doesn't work
相关文章
- Popover segue to static cell UITableView causes co
- Creating UIImage from CIImage
- UIAlertViewStylePlainTextInput return key delegate
- AVCaptureDeviceOutput not calling delegate method
- How to call an action when UISwitch changes state?
- Making any tweet favourite through iOS 5 twitter A
- Unable to pass NSManagedObjectContext to my view c
- iOS 5.1 Reachability
As others pointed out you can use
BUT be very careful because you will run into problems (talking from experience here) look at this: IOS5 setBrightness didn't work with applicationWillResignActive and this: Anyone been able to use [[UIScreen mainScreen] setBrightness] on background / exit?
(I wish I had, when I discovered this thread/answer) :-(
I have never tried it, but looking at the docs it should go like this:
The
UIScreen
class has a new property calledbrightness
.In addition, there's another property called
wantsSoftwareDimming
that (when set toYES
) allows you to go below the lowest brightness supported by the hardware, because a special "dimming view" is overlaid over the screen to darken things even further.The
brightness
property takes a float from0
to1
. So:wantsSoftwareDimming
set toNO
(the default), abrightness
of0
means "the darkest the hardware supports" and abrightness
of1
means "the brightest the hardware supports".wantsSoftwareDimming
set toYES
, abrightness
of0
means "the darkest the hardware supports PLUS darkening by overlaying a dimming view", and abrightness
of1
still means "the brightest the hardware supports".You can use either of these two:
[[UIScreen mainScreen]setBrightness:1.0];
GSEventSetBacklightLevel(0.5f);
But this is a private API call, if you use it, your application will surely be rejected.