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
John Perry
Full Stack JavaScript Techdegree Graduate 41,012 PointsThis seems like a ton of code just to make it a little easier to create colors; am I missing something?
If I want to create a light blue color, all that I have to do is this:
UIColor(red: 3/255.0, green: 169/255.0, blue: 244/255.0, alpha: 1.0)
Am I missing something, or does this video just explain how to not write UIColor and 255.0 after each color value?
1 Answer
Taraj Shah
21,073 PointsNo. I think you are right. You have to.
Just because this method only accepts values of R,G & B in the range of 0.0 to 1.0, while the color values ranges from 0.0 to 255.0. So, to convert the range of (0 to 255) to (0 to 1), you simply have to divide that with 255.0