2
-(IBAction)changeslidervalue:(id)sender
{
NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];   
float values = [defaults2 floatForKey:@"slider_preference"];
NSLog(@"value of slider %f",values);

if(imageView == nil){
imageView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 500, 500)];


imageView.backgroundColor = [UIColor whiteColor];
imageView.userInteractionEnabled  = NO;
}
if(values < 0.1){
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.4;
}
else if((values < 0.2) && (values > 0.1)) {
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.2;
}
else if((values < 0.3) && (values > 0.2)) {
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.1;
}
else if((values < 0.4) && (values > 0.3)) {
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.0;
}
else if((values < 0.5) && (values > 0.4)) {
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.1;
}
else if((values < 0.6) && (values > 0.5)) {
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = 0.2;
}

NSLog(@" Brightness is %f",values );
[self.view addSubview:imageView];
[self.view bringSubviewToFront:imageView];
[imageView release];

}

我正在使用此代码单击相机按钮(运行时间),然后更改拍摄照片或视频的亮度。请有人帮助我或解决我的问题。

4

0 回答 0