Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone brightness private API not working properly

I am trying to set the brightness of the backlight, but it's acting very strangely. I am using the private API:

[(id)[UIApplication sharedApplication] setBacklightLevel:1.0f];

However, when I call this, the screen dims, not becoming 100% bright like I thought it would. I have tested this with a variety of numbers, and here is what I got:

0.2: dark

0.3: light

0.4: dark

0.5: dark

0.6: light

0.7: dark

0.8: dark

0.9: dark

1.0: dark

1.1: dark

1.2: light

1.3: dark

1.4: dark

1.5: light

Some of the values were slightly brighter than the darkest values, but that is the overall trend. It doesn't seem like the pattern makes any sense. Does anyone know what scale the brightness should be on?

like image 331
Ned Avatar asked Dec 06 '25 16:12

Ned


1 Answers

The problem is that the compiler doesn't know a method takes a float unless you declare it. So the float you pass in is getting converted to another type when you pass it and then that new bit pattern being reinterpreted as a float by the method. You just need to have the method declared in a header that file knows about and the float will be passed unaltered.

like image 155
Chuck Avatar answered Dec 08 '25 08:12

Chuck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!