set background image for entire iPhone / iPad app
I have a single image I want as the background for my app no matter what viewcontroller they are on - how do you accomplish this?
Solution 1:
Here's how you set a background to an image:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Background.png"]];
Edit: To write up what Felixyz said (and thanks to Manni), do this in your delegate:
window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Background.png"]];
And in each view you want to have the image, do this:
self.view.backgroundColor = [UIColor clearColor];
Solution 2:
Depends on what sort of interface you have. Tabbed? Navigation based? But the general answer is: add a UIImageView to your UIWindow before/below your main view. Then make every view handled by your main view controller have a transparent background. Hard to give more specific advice without knowing if you use IB or not, or what your view hierarchy looks like.
Solution 3:
In my app, I set a default background color. Maybe you can do this with you background image:
1.: Set the background color of your UIWindow in your AppDelegate:
window.backgroundColor = [UIColor myBackgroundGray]; // own Category
2.: And now, make all other views transparent:
self.view.backgroundColor = [UIColor clearColor]; // = transparent