iOS Build a Simple iPhone App with Swift Improving Our User Interface Changing the Background Color

A bit confused as to what to input

not to sure what to input into this section. I guess I'm getting confused because I do not have a viewController to go off of. What do i type to make this pass??

ViewController.swift
class ViewController: UIViewController {

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

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

1 Answer

Jaroslaw Adamowicz
Jaroslaw Adamowicz
11,634 Points

Hi,

in this challange you have class with two methods inside.

Your first task is to add new property. Class property can be variable or constant named blueColor, so either:

let blueColor = UIColor.blue

or

var blueColor = UIColor.blue

You can always use more advanced way of course using UIColor initializer directly, like this for example:

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

Just keep in mind, one of this lines should be added somewhere inside of the ViewController class, but not inside of the methods!

Your second task is to use this property to change background of the view inside ViewController. Remember, view is literally a property of ViewController!

Also you one to do this in method called viewDidLoad. This method should be self-explanatory, IOS calls this method when your view is ready and load, so you can now customize it (like change its background) :D

So it will look like this:

view.backgroundColor = blueColor

That's all to it!

Let me know if you still need some help.

Cheers!

BR, Jarek