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 trialGregory Millan
3,719 PointsTint color on the button not coinciding with background color
Here is my code below.
@IBAction func showFunFact() {
let randomColor = ColorModel().getRandomColor()
view.backgroundColor = randomColor
funFactButton.tintColor = randomColor
funFactLabel.text = factBook.getRandomFact()
}
As you can see from the code above, the background color and tint color are both set to randomColor. However, the tint color is not changing when i runt the app. Everything else happens to fine though.
1 Answer
Steven Deutsch
21,046 PointsHey Gregory Millan,
Are you trying to change the color of you button to a random color as well? If so, what you need to be setting the random color on is the UIButton's backgroundColor property.
// It would look like this
funFactButton.backgroundColor = randomColor
Hope this is the answer you were looking for.
Timothy Kaye
2,765 PointsTimothy Kaye
2,765 PointsGregory, how did you go with sorting this out?
Can you post your 'ColorModel.swift' file so that we can see if there is a typo?