Swift 3: How to Create CFArray of CGColors?
Swift 3: How to Create CFArray of CGColors?
- Subject: Swift 3: How to Create CFArray of CGColors?
- From: Charles Jenkins <email@hidden>
- Date: Tue, 22 Nov 2016 19:17:58 -0500
I’m sure this will turn out to be elementary, but the Apple documentation
of CFArray is so EMPTY that I can’t seem to figure it out.
I have this line of code:
let gradient = CGGradient( colorsSpace: CGColorSpaceCreateDeviceRGB(),
colors: [ clearWhite.cgColor, clearWhite.cgColor,
clearWhite.blendedColorWithFraction(0.5, ofColor: white).cgColor,
white.cgColor ], locations: [0, 0.57, 0.93, 1])
The array of colors is no longer legal in Swift 3. I get an error
message—“Contextual type CFArray cannot be used with an array
literal”—which I think is saying I must pass a CFArray.
Despite Xcode crashing every few minutes while I’m typing, I was able to
create a CFMutableArray object, but then I get an error when trying to add
the colors because they aren’t unsafe pointers.
How can I convert my array to the needed CFArray?
--
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden