PDA

View Full Version : background image and self.view -- quick change




tawpie
Aug 2, 2008, 12:59 PM
ok... I put a background image on my app, sort of like wallpaper. It's pretty easy to do, I start with a UIImageView, set the background image, add some labels and buttons, then copy it to self.view.

Now, I want to change the background image only, not the labels, not the buttons BUT since self.view is evidently not a UIImageView, one cannot set the background image.

I tried a mutable copy of self.view to a "new" UIImageView, that blows up at the mutable copy.

I can do it via subviews but that seems like a longer way around since I get to create my buttons and labels for each different wallpaper.

Suggestions are highly appreciated!



kainjow
Aug 4, 2008, 08:54 PM
How are you doing it without subviews? You can assign self.view to an image view - it doesn't have to be a normal view.

tawpie
Aug 5, 2008, 12:22 AM
yep, I haven't gotten subviews "down" yet... soon though. Turns out you can do what I wanted. The solution is that self.view can be a UIImageView, but the compiler doesn't quite know about it so the .image property doesn't function UNLESS you tell the compiler it's dealing with a UIImageView. I had figured if you can assign a UIImageView to self.view you should be able to modify the .image property, thanks to Sbrocket for this solution, which tells the compiler that self.view has a .image property:

((UIImageView*)self.view).image = [UIImage imageNamed:@"myNewImage.png"];