我看过这个 WWDC 会议及其示例项目:https ://developer.apple.com/documentation/pencilkit/inspecting_modifying_and_constructing_pencilkit_drawings
但是,当我尝试在我的绘图画布上绘制 CGPoints 时,什么也没有出现。
这是我的设置:
var points: [CGPoint] = []
(500...1000).forEach { x in
(500...1000).forEach { y in
points.append(CGPoint(x: x, y: y))
}
}
let strokePoints = points.map {
PKStrokePoint(location: $0, timeOffset: 0, size: CGSize(uniform: 1), opacity: 2, force: 1, azimuth: 1, altitude: 1)
}
let strokePath = PKStrokePath(controlPoints: strokePoints, creationDate: Date())
let stroke = PKStroke(ink: PKInk(.pen, color: .systemGreen), path: strokePath)
canvasView.drawing = PKDrawing(strokes: [ stroke ])