Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

ios5 - How to change brightness in iOS 5 app?

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The UIScreen class has a new property called brightness.

In addition, there's another property called wantsSoftwareDimming that (when set to YES) 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 from 0 to 1. So:

  • with wantsSoftwareDimming set to NO (the default), a brightness of 0 means "the darkest the hardware supports" and a brightness of 1 means "the brightest the hardware supports".
  • with wantsSoftwareDimming set to YES, a brightness of 0 means "the darkest the hardware supports PLUS darkening by overlaying a dimming view", and a brightness of 1 still means "the brightest the hardware supports".

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...