Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!