how to change the backgrond color of view controller from other controller in the app ?
+1
A:
To change the background color of a 'view' you need to set the backgroundColor property on it. This implies that you have access to it. If it was all in one controller you would just use
self.view.backgroundColor = [UIColor redColor];
If it was in a navigation or similar based app, then you can access a views parentViewController and change the color on it as follows:
self.parentViewController.view.backgroundColor = [UIColor redColor];
If this is not possible then you can set an iVar on the second view controller when it is created that contains the instance of the viewController that you want to change the background color on.
MyViewController* secondViewController = [[MyViewController alloc] init];
secondViewController.bgColorNeedsChangingViewController = self;
Then in the secondViewController's logic
self.bgColorNeedsChangingViewController.view.backgroundColor = [UIColor redColor];
Liam
2010-01-04 12:15:30
A:
UIViewController *yourVC;
UIColor *colour = [[UIColor alloc] initWithRed: 1.0 green: 0.0 blue: 0.0 alpha: 1.0];
[yourVC.view.backgrounColor] = colour;
[colour release];
Frank Shearar
2010-01-04 12:16:14