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

UIColor is an unresolved identifier, while running the test code in the playground. How to fix that?

I wrote, var redColor = UIColor(red : 223/255.0, green : 86/255.0, blue : 94/255.0, alpha : 1.0)

4 Answers

Did you remember import UIKit at the top of your code?

Yes I did, some other problem. Thanks.

Do you have some other code in the playground that may cause the problem? Do you have the latest version of Xcode? It works for me when I copy your code over to an empty playground with import UIKit at the top.

I wasn't working in the playground, I was writing in a separate swift file. Yes, I have the latest version of Xcode and I tried both @import UIKit and import UIKit at different times. I switched the simulator to iPhone 5s from iPhone 5 and it worked, don't know how.