Can't set background colour for UIView from ViewController
- by Curyous
I have the following code in the view controller:
- (void)viewDidLoad {
[super viewDidLoad];
ThemeManager *themer = [ThemeManager sharedInstance];
UIView *theView = self.view;
UIColor *forBackground = [themer backgroundColour];
[theView setBackgroundColor:forBackground];
}
but when execution gets to the setBackgroundColor line, I get the following error:
*** -[NSCFNumber CGColor]: unrecognized selector sent to instance 0x1237c40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFNumber CGColor]: unrecognized selector sent to instance 0x1237c40'
There's got to be something simple that I'm doing wrong, how do I set the background colour?
Do I have to subclass the view and do it in there? I'd prefer not to have the extra class, even though that is better separation of the whole model/view/controller thing.
Update: value returned by [themer backgroundColour] is constructed using colorWithPatternImage:, could this make a difference?