Render a line graph on Apple Watch using watchOS 2

前端 未结 5 1125
说谎
说谎 2021-02-01 11:13

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

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 11:26

    Here's the example project that shows how to do dynamic graphs on WatchKit 2.0

    https://github.com/vlm/ExampleWatchGraph

    The gist of it is in the GraphPainter.swift file, where CoreGraphics is used to draw into an off-screen buffer (as @shu223 suggested), then display this buffer in a WKInterfaceImage.

    Animated Watch Interface GIF.

提交回复
热议问题