I am trying to render a line/step graph on Apple Watch using watchOS 2. Unlike iOS 9, watchOS 2 doesn\'t support Quartz. It only supports Core Graphics. I tried writing some cod
Here's code in watchOS 3
// Create a graphics context
let size = CGSize(width:self.contentFrame.size.width, height:100)
UIGraphicsBeginImageContext(size)
let context = UIGraphicsGetCurrentContext()
// Setup for the path appearance
context!.setStrokeColor(UIColor.white.cgColor)
context!.setLineWidth(4.0)
// Draw lines
context!.beginPath ();
context?.move(to: CGPoint())
context?.addLine(to: CGPoint(x: 100, y: 100))
context?.addLine(to: CGPoint(x: 0, y: 100))
context?.addLine(to: CGPoint(x: 100, y: 0))
context!.strokePath();
// Convert to UIImage
let cgimage = context!.makeImage();
let uiimage = UIImage(cgImage: cgimage!)
// End the graphics context
UIGraphicsEndImageContext()
self.graphGroup.setBackgroundImage(uiimage)