Okay, this question comes through a friend so it might be lost in translation...
Basically we need to change the color on a View. It appears to be stored in NSString
format, but using a NSString
to set the UIColor
doesn't seem to do anything. In other words, if NSString color
holds the value "redColor" then:
self.view.backgroundColor = color; //does nothing
Disclaimer: we are Objective-C/iPhone newbies.
Method 2 − Programmatically changing the backgroundCreate outlet of the button on the View Controller. In the viewDidLoad() or viewWillLayoutSubview() method add the code to change the background color.
backgroundColor =[UIColor colorWithRed:178/255. f green:14/255. f blue:12/255. f alpha:0.05];
Find the view or view controller you want to change the background color of. Open it up in the interface builder and open the Attributes Inspector. Find the background color field and set it to the color you want.
Try
self.view.backgroundColor = [UIColor redColor];
You can also give RGB values like
self.view.backgroundColor = [UIColor colorWithRed:200/255.0 green:0/255.0 blue:67/255.0 alpha:1.0];
All the Best.
The color must be a UIColor object:
self.view.backgroundColor = [UIColor redColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With