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 Random Colors

I dont get the button text to switch color

@IBAction func showFunFacts() { let randomColor = ColorModel().getRandomColor() view.backgroundColor = randomColor funFactButton.tintColor = randomColor funFactsLabel.text = factModel.getRandomFact()

5 Answers

Think it's a bug.

Hi, Kjetil. I've tested your code - and it works just fine.

Your code doesn't contain a closing curly brace - probably you posted not the whole body of the function and you are setting .tintColor somewhere later to a fixed color?

.tintColor did not work for me either but .setTitleColor did.

    @IBAction func loadFact() {
        let randomColor = colorModel.getRandomColor()
        view.backgroundColor = randomColor
        funFactButton.setTitleColor(randomColor, forState: .Normal)
        funFact.text = factModel.getRandomFact()
    }

button color doesn't change for me either. (Using Xcode 8.0)

.tintColor didn't work for me either, but .setTitleColor worked. Using Xcode 7.3.1