I am developing a eBook reader app for iPad and i want to add a feature where in the user can adjust the brightness of the device from the app. Is there anyway in which i can implement this in my app..???
Asked
Active
Viewed 1,768 times
2
-
1possible duplicate of [Change Backlight Brightness on iPhone Programmatically](http://stackoverflow.com/questions/366889/change-backlight-brightness-on-iphone-programmatically) – Claus Broch May 27 '11 at 09:10
-
sorry, i have checked SOF before posting the question, but i could find nothing. So, i posted this question. Anyway, i have found the answer for my question and i have posted it here in the answers column. – A for Alpha May 27 '11 at 10:36
2 Answers
1
I found rather a simple solution for it. I am adding a UIVIew of clear color to my book reader view and i am increasing the alpha component of this view upon the slider value changed event. By doing this , my view gets darkened and we get a feeling that the brightness of the app is reduced.. This solution may not be very appropriate, but works just fine in my case. Any better solutions are always appreciated.Thank you...

A for Alpha
- 2,904
- 8
- 42
- 76
-
Can you please post some codes ? I am not getting exactly and I need the same thing to be implemented in my app as well. Regards ! – Akshay Jun 17 '11 at 04:36
0
well, its not the exact solution, but it will serve the purpose...
-(IBAction)sliderValueChangedForBrightness:(UISlider*)sliderObj{
brightnessView.backgroundColor=[[UIColor grayColor] colorWithAlphaComponent:1-sliderObj.value];
}
-(IBAction)adjustBrightness:(UIButton *)sender{
if(isbrightnessViewShowing==NO){
isbrightnessViewShowing=YES;
[self.view addSubview:brightnessSliderView];
brightnessSliderView.frame=CGRectMake(sender.frame.origin.x-70,brandingView.frame.size.height, brightnessSliderView.frame.size.width, brightnessSliderView.frame.size.height);
}
else {
isbrightnessViewShowing=NO;
[brightnessSliderView removeFromSuperview];
}
if (brightnessView==nil) {
brightnessView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
brightnessView.backgroundColor = [UIColor clearColor];
}
[webView addSubview:brightnessView];
[webView bringSubviewToFront:brightnessView];
}

IronManGill
- 7,222
- 2
- 31
- 52

A for Alpha
- 2,904
- 8
- 42
- 76