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

Seyran Basak
Seyran Basak
5,660 Points

Challenge task 2 Background Property

I know this must be a simple mistake but I can't seem to figure out task 2 here after trying it a bunch of times. Thanks for any help.

colors.swift
class ViewController: UIViewController {

    let blueColor = UIColor(red: 0, green: 0, blue: 255, alpha: 1.0)
    view.backgroundColor = blueColor

    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
    }
}

2 Answers

Seyran, very close. You just changed the background color of the backing view in the wrong place. That line has to be in the viewDidLoad() function, i.e., after the view is loaded:

class ViewController: UIViewController {

    let blueColor = UIColor(red: 0, green: 0, blue: 255, alpha: 1.0)


    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
    }
}
Bruce Rรถttgers
Bruce Rรถttgers
18,211 Points

So thankful! I searched for it so long!

Seyran Basak
Seyran Basak
5,660 Points

Thank you jcorum! I knew it was something minor, I understand it now.