I am trying to set the background image of my view controller based on a property I set while it is initialized in the first layer of a navigation controller. In other words, before I tell my navigation controller to push the new view controller.
instead of manually typing in a bunch of if statements, I’m trying to find a way to do this automatically – I’ve tried this but it doesn’t seem to work:
NSString *backgroundImageName = [[NSString alloc]initWithFormat:@"artistbackground%i.png",_artistID];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:[NSString stringWithFormat:@"@\"%@\"",backgroundImageName]]];
The string would correspond to the image title in my support files.
This hasn’t been working does anyone have any other methods for handling this?
Thanks!!
Try this: