Converting UIColor to CGColor in swift
This is the Obj-C code:
CGContextSetStrokeColorWithColor(context, [[UIColor lightGrayColor] CGColor]);
How do I write it in swift.
2 Solutions Collect From Internet About “Converting UIColor to CGColor in swift”
// Original answer. var newColor = UIColor.lightGrayColor().CGColor // Swift 3 version var newColor = UIColor.lightGray.cgColor
Oddly enough, as Swift has evolved to 3.0 the answer has evolved as well. I ran across this while converting some Objective C code to Swift. I hope this helps someone! 🙂 Here is what it is today:
And it’s funny, this “light gray” answer is actually helping me debug some code too! Thank iou!
- Xcode tree conflicts on merge
- New XCode Crash Organizer Does Not Symbolicate .xccrashpoint Files
- Property vs Instance Variable
- Serving non-Retina and Retina displays with one code base: framework for scaling layouts and assets for HTML5 apps on iPhones or iOS devices?
- Restkit request not sending parameters
- Measuring Time Accurately in Swift for Comparison Across Devices
- Can't auth to Facebook with iOS SDK and native Facebook application
- How to create .doc file or word processor in iOS application?
- Developing for iphone under unix
- How can I set the UIImagePickerController orientation for video?
- Can you pass WiFi settings from an iOS device to an ExternalAccessory object?
- Difference Between Completion Handler and Blocks :
- How to convert NSUrl to NSString?
- AlertController is being popped every time in nested conditions swift ios
- Operation Queue vs Dispatch Queue for iOS Application