views:

255

answers:

2

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.

+3  A: 

Try

self.view.backgroundColor = [UIColor redColor];

You can also give RGB values like

self.view.backgroundColor = [UIColor colorWithRed:200/256.0 green:0/256.0 blue:67/256.0 alpha:1.0];

All the Best.

Warrior
Thanks, I'll tell my friend to try this, but two identical answers seems promising :)
miorel
+1  A: 

The color must be a UIColor object:

self.view.backgroundColor = [UIColor redColor];
Ole Begemann
Thanks, I'll tell my friend to try this, but two identical answers seems promising :)
miorel