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

Paul Je
Paul Je
4,435 Points

Don't get it again lol

Thanks for any help.. would be greatly appreciated - I'm not sure how to reference the backgroundColor nor do I understand what type of property it is: is it a UIViewController pre-made property or is it something I am supposed to create a let statement to create a constant in order to create the property? Thanks!

colors.swift
class ViewController: UIViewController {

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

    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
    }

  let backgroundColor = blueColor
}

2 Answers

Anjali Pasupathy
Anjali Pasupathy
28,883 Points

You're very close! To access the view's background color, you just need to use view.backgroundColor:

view.backgroundColor = blueColor

You also need to put this line of code inside the viewDidLoad() function.

I hope this helps!

Paul Je
Paul Je
4,435 Points

thank you thank you x 3!