Translate

Sunday, March 18, 2012

Brightness control using uislider for ios 5.0

UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(240, 33, 100, 50)];//240, 0, 100, 50: 50, 35, 250, 30
                slider.minimumValue=0;
                slider.maximumValue=1;
                slider.value = 1;
                [slider setMinimumTrackTintColor:[UIColor colorWithRed:.1 green:.7 blue:0 alpha:1.0]];
                [slider setMaximumTrackTintColor:[UIColor blackColor]];
                [slider addTarget:self action:@selector(brightnesssliderMove:) forControlEvents:UIControlEventTouchUpInside];
                [slider addTarget:self action:@selector(brightnesssliderMove:) forControlEvents:UIControlEventTouchUpOutside];
                float sliderValue = slider.value;
                brightValue = [NSString stringWithFormat:@"%f", sliderValue];


 -(void)brightnesssliderMove:(UISlider *)sender
{
         brightValue = [NSString stringWithFormat:@"%.1f", [sender value]];
       // [ViewController viewAlpha:brightValue];
}

-(void)viewAlpha:(NSString*)string
{
    [UIScreen mainScreen].brightness = [string floatValue];
}

No comments:

Post a Comment