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

UIColor From Variables

Hello,

I'm trying to make an iOS application that has three sliders, one for each red, green, and blue. Each time a slider is moved the current value is assigned to a variable. My problem is that I would like to set the background color to the variables that were set. The syntax that I'm familiar with is,

view.backgroundColor = UIColor(red: 102/255.0, green: 204/255.0, blue: 255/255.0, alpha: 1.0)

So what I'm trying to do in my head looks like,

view.backgroundColor = UIColor(red: returnedValueOfRedSlider/255.0, green: returnedValueOfGreenSlider/255.0, blue: returnedValueOfBlueSlider/255.0, alpha: 1.0)

but it has been made apparent that this is a big no no. So what can I do to use variables to make a UIColor to assign to the backgroundColor?

Thank you,