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!
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
Joshua Rapoport8,415 Points
Drawing Code for Linear Gradient isn't working
I'm using Xcode 7 for this course, so I found that part of my code wouldn't compile. This is the drawing code for a linear gradient which provided for both Xcode 6 and 7. I tried both. The snippet for Xcode 6 gave a compiler error for the constants
kCGGradientDrawsAfterEndLocation. The Xcode 7 snippet, contained in a project download, compiled, but no gradient appeared in the WeeklyTableViewController.
Nathan Tallack22,159 Points
For some reason the constants are not available to the function. No idea why.
I managed to get it working by calling it with the built in option flag. Unfortunatly it seems you can only call either drawsbefore or drawsafter, looks like you cant call both. Looks ok just calling drawsafter though.
So, replace the line
UInt32(kCGGradientDrawsBeforeStartLocation) | UInt32(kCGGradientDrawsAfterEndLocation))
Giedrius Zavadskas6,427 Points
Replace this: UInt32(kCGGradientDrawsBeforeStartLocation) | UInt32(kCGGradientDrawsAfterEndLocation))
with this: [.DrawsAfterEndLocation, .DrawsBeforeStartLocation])
Tommy Choe38,156 Points
Hey all, just wanted to let you know that Pasan answered this question on this forum post: https://teamtreehouse.com/community/use-of-unresolved-identifier-kcggradientdrawsbeforestartlocation
He explains why its not working.
Hope that helps.
Ramesh VJ2,201 Points
@ Nathan Tallack : It worked on Xcode 7. Thanks for ur help.