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 Improving Our User Interface Adding a Pop of Color

.tintColor does not work in Swift anymore (??)

I've watched "adding a pop color" video, part of Build a Simple iPhone App with Swift, and I had to change the tint color of a button. However the .tintColor did not work after assigning it properly (according to the video).

My code:

```import UIKit

class ViewController: UIViewController {

@IBOutlet weak var funFact: UILabel!
@IBOutlet weak var funFactButton: UIView!

let factBook = FactBook()
let colorWheel = ColorWheel()
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    funFact.text = factBook.randomFact()
}

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

@IBAction func showFunFact() {

    let randomColor = colorWheel.randomColor()
    view.backgroundColor = randomColor
    funFactButton.tintColor = randomColor


    funFact.text = factBook.randomFact()


}

}```

2 Answers

Omar Nunez
Omar Nunez
4,101 Points

set "canDisplayBannerAds" to "true" in the properties of your project

That does not work, sadly. I've set canDisplayBannerAds true in the ViewController (viewDidLoad function) and it does not work, besides that I had to import the iAd kit before I was able to set it to true.

Omar Nunez
Omar Nunez
4,101 Points

try create the button from 0, maybe the type change with a upgrade.