some_id
some_id

Reputation: 29886

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

Upvotes: 0

Views: 374

Answers (2)

John Smith
John Smith

Reputation: 12797

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)

Upvotes: 2

syoleen
syoleen

Reputation: 281

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

Upvotes: 1

Related Questions