Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How can I achieve this effect in an iOS App?

I am creating my first ever iOS app, which is based off the Crystal Ball app.How can I make it so that whenever a new random thing is displayed that there is also a different background image and a link to a webpage?

1 Answer

Stone Preston
Stone Preston
42,016 Points

For the random background image part you would need to create an array of UIImages to use as the background and a randomImage method much like the randomPrediction method. You would need to add a UIImage to your storyboard and connect it as an outlet. then whenever the button is pressed/screen is tapped or whatever you would need to call the randomImage method you created that returns a random UIImage from the images array and set that as the background.