Quote:
Originally Posted by chenxintao
Hi,I want to use GSEventSetBacklightLevel, and I have #import "GraphicsServices.h", but there is a error. "_GSEventSetBacklightLevel", referenced from: .... symsbol not found.
And I can't find GraphicsServices.framework.How can I do to use GSEventSetBacklightLevel ?
|
Hi,
i Managed to get it working, maybe you/someday some else can find your/his solution with my code snip.
I used to change the backlight level with a UISlider, and programmatically with some "pulse" effect.
some vars needed in my code
Code:
// init global vars
_currentBacklightLevel = 0.2f;
[self setBacklightLevel:_currentBacklightLevel];
_pulseBacklightDirection = 0; // 0 = off, 1 = up, 2 = down
Creating my slider
Code:
// create brightnessSlider
brightnessSlider = [[UISlider alloc] initWithFrame:CGRectMake(18.0f, 420.0f, 258.0f, 23.0f)];
[brightnessSlider addTarget:self action:@selector(brightnessSliderChanged:) forControlEvents:UIControlEventValueChanged];
[brightnessSlider setBackgroundColor:[UIColor clearColor]];
brightnessSlider.minimumValue = 0.0;
brightnessSlider.maximumValue = 1.0;
brightnessSlider.continuous = YES;
brightnessSlider.value = _currentBacklightLevel;
[self.view addSubview:brightnessSlider];
The main method, remember you won't pass appstore policy with this.
Code:
- (void)setBacklightLevel: (float)newLevel {[(id)[UIApplication sharedApplication] setBacklightLevel:newLevel]; // newLevel between 0.0f and 1.0f
}
My pulse function, just some little play i made
Code:
- (void)pulseBacklight {
if (_pulseBacklightDirection > 0) {
if (_pulseBacklightDirection == 1) {
if (_currentBacklightLevel < 0.975f) _currentBacklightLevel += 0.025f;
else _pulseBacklightDirection = 2;
}
else if (_pulseBacklightDirection == 2) {
if (_currentBacklightLevel > 0) _currentBacklightLevel -= 0.025f;
else _pulseBacklightDirection = 1;
}
[self setBacklightLevel: _currentBacklightLevel];
brightnessSlider.value = _currentBacklightLevel;
[self performSelector:@selector(pulseBacklight) withObject:nil afterDelay:0.01f];
}
else {
[self setBacklightLevel:0.5f];
_currentBacklightLevel = 0.5f;
}
}
Hope someday someone will see this, smile, and get his work done
Greetings
Max