Ok, I’m making an app for iPhone that lets you drag three sliders and view the created RGB Value. For the moment, I’m just making it control each slider’s label (here’s my layout:
RGB Color Viewer (eventually this will be in the overall color)
Red Value (supposed to be {Value of slider, 0, 0} )
Slider (from 0 to 1)
Green Value (supposed to be {0, Value of slider, 0} )
Slider (from 0 to 1)
Blue Value (supposed to be {0, 0, Value of slider} )
Slider (from 0 to 1)
Ok, here’s my header’s interface code: (the .h file)
@interface RGB_ColorsViewController : UIViewController {
IBOutlet UISlider *redSlider;
IBOutlet UISlider *greenSlider;
IBOutlet UISlider *blueSlider;
IBOutlet UILabel *redLabel;
IBOutlet UILabel *greenLabel;
IBOutlet UILabel *blueLabel;
}
-(IBAction)updateredLabel:(id)sender;
-(IBAction)updategreenLabel:(id)sender;
-(IBAction)updateblueLabel:(id)sender;
@end
And in my main file I have this: (the .m file)
@implementation RGB_ColorsViewController
-(IBAction)updateredLabel:(id)sender {
redLabel.textColor = [UIColor colorWithRed:[@“%.0f” floatValue]/255 green:0 blue:0 alpha:1.0];
}
-(IBAction)updategreenLabel:(id)sender {
greenLabel.textColor = [UIColor colorWithRed:0 green:[@“%.0f” floatValue]/255 blue:0 alpha:1.0];
}
-(IBAction)updateblueLabel:(id)sender {
blueLabel.textColor = [UIColor colorWithRed:0 green:0 blue:[@“%.0f” floatValue]/255 alpha:1.0];
}
And then it continues with the normal stuff. So how do I link the buttons and slider I made in the .xib file to the redLabel, blueLabel etc. variables I declared in my other files? This is my first app so be nice Lol, thanks people!