简体   繁体   中英

How do I change the background image of my iPhone app?

I have looked around and found some code which so called chooses an image from an array of image objects, but cant find an explanation.

I would like to make my app have a background image and the user can select next and previous buttons to scroll through some full screen images, setting them as the background image as they scroll.

I know how to do this in java, but cant seem to do it for this app.

How or what code is linked to a next button to grab the next image in the array and reverse for the back button?

Then that needs to be displayed obviously.

I have used a layered architecture with a MVC style approach but cant seem to put it together with Objective-C.

Would the buttons call the appropriate methods of the so called delegates, which the delegates handle fetching and returning the Images?

Would the buttons use the returned images and actually handle the redrawing?

I would really appreciate the help.

Regards

Jarryd

Extend the answer by syoleen.

NSArray * names = [NSArray arrayWithObjects:@"file1.png" @"file2.png",@"file3.png",nil];
int r=rand()%([NSArray count]);
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:[names objectAtIndex:r]]];

(this is from memory so might have few typos)

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@“ pic.png”]]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM