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 Build a Simple iPhone App with Swift 2.0 Improving Our User Interface Changing the Background Color

UIColor challenge

Need help i don't understand it thanks :)

colors.swift
class ViewController: UIViewController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated
    }
}

1 Answer

David Papandrew
David Papandrew
8,386 Points

Hi Alia,

So you need to add two lines of code to solve this: 1) Create a constant (the stored property) and assign it the blue color 2) Set the view.backgroundColor in the viewDidLoad() function to the blue color

Here's what worked for me:

class ViewController: UIViewController {

    let blueColor = UIColor.blueColor()

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.
        view.backgroundColor = blueColor
    }

    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated
    }
}