如何修改PKDrawing中的个别笔画? - PencilKit / SwiftUI
How to modify individual strokes in PKDrawing? - PencilKit / SwiftUI
我想更改绘图中单个笔划的颜色。打印 PKDrawing().strokes
returns 一个包含多个 PencilKit.PKStroke
项的数组,我可以从反映在 canvas 上的数组中删除笔划。但是,如果我想改变第一笔画的颜色,我该怎么做呢?
谢谢!
需要修改笔划的墨色,赞
let canvasView = PKCanvasView() // assuming we some this somewhere above
...
if !canvasView.drawing.strokes.isEmpty {
// set color whichever needed
canvasView.drawing.strokes[0].ink.color = UIColor.red // << here !!
}
测试 Xcode 12.1 / iOS 14.1
我想更改绘图中单个笔划的颜色。打印 PKDrawing().strokes
returns 一个包含多个 PencilKit.PKStroke
项的数组,我可以从反映在 canvas 上的数组中删除笔划。但是,如果我想改变第一笔画的颜色,我该怎么做呢?
谢谢!
需要修改笔划的墨色,赞
let canvasView = PKCanvasView() // assuming we some this somewhere above
...
if !canvasView.drawing.strokes.isEmpty {
// set color whichever needed
canvasView.drawing.strokes[0].ink.color = UIColor.red // << here !!
}
测试 Xcode 12.1 / iOS 14.1