Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tawpie

macrumors newbie
Original poster
Jul 8, 2008
18
0
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

Moderator emeritus
Jun 15, 2000
7,958
7
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

macrumors newbie
Original poster
Jul 8, 2008
18
0
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:mad:"myNewImage.png"];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.