我正在使用带有TouchCanvas(Apple Pencil Sample App)的swift 2.3,
在绘图时,
我可以在钢笔/铅笔/刷子/橡皮擦之间切换 - 厚度&相应地应用颜色和相同的颜色。
现在我升级到swift 3.0,
哪张图,
在笔/铅笔/刷子/橡皮擦之间切换时 - 厚度&颜色,最后一个选择的颜色应用于ALL。
并尝试了最新的pencil API ..结果相同
可以请任何人告诉我这方面的确切解决方案..
答案 0 :(得分:1)
啊......经过长时间的努力......找到了解决办法......
CanvasView.swift上只有一行
override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()!
context.setLineCap(.round)
needsFullRedraw = false //添加了这一行
if (needsFullRedraw) {
setFrozenImageNeedsUpdate()
frozenContext.clear(bounds)
for array in [finishedLines,lines] {
for line in array {
line.drawCommitedPointsInContext(frozenContext, isDebuggingEnabled: isDebuggingEnabled, usePreciseLocation: usePreciseLocations)
}
}
needsFullRedraw = false
}
frozenImage = frozenImage ?? frozenContext.makeImage()
if let frozenImage = frozenImage {
context.draw(frozenImage, in: bounds)
}
for line in lines {
line.drawInContext(context, isDebuggingEnabled: isDebuggingEnabled, usePreciseLocation: usePreciseLocations)
}
}
或只是评论了以下一行
/*if (needsFullRedraw) {
setFrozenImageNeedsUpdate()
frozenContext.clear(bounds)
for array in [finishedLines,lines] {
for line in array {
line.drawCommitedPointsInContext(frozenContext, isDebuggingEnabled: isDebuggingEnabled, usePreciseLocation: usePreciseLocations)
}
}
needsFullRedraw = false
}*/