我想使用从步进器获得的 rgb 值更改视图的背景,由于某种原因它不起作用,请帮助!
int red1,green1,blue1;
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
}
-(IBAction)stepper:(UIStepper *)mystep
{
if(mystep.tag==1)
{
red1=(int)mystep.value;
txt1.text=[NSString stringWithFormat:@"%d",red1];
}
if(mystep.tag==2)
{
green1=(int)mystep.value;
txt2.text=[NSString stringWithFormat:@"%d",green1];
}
if(mystep.tag==3)
{
blue1=(int)mystep.value;
txt3.text=[NSString stringWithFormat:@"%d",blue1];
}
}
-(IBAction)btnPressed
{
view1.backgroundColor=[UIColor colorWithRed:red1 green:green1 blue:blue1 alpha:1.0];
}