![](/img/trans.png)
[英]ios-UIBezierPath stroke by percentage for anti-clockwise with start for arc is from vertical downward position
[英]How to not stroke() every UIBezierPath in array
我正在開發一個手寫應用程序,並且正在使用三個不同的UIBezierPath變量:
我使用的是路徑數組,而不是單個路徑,因為我有一個平移工具可以在屏幕上移動線條-因此它們需要是單獨的實體。 問題在於,每次調用draw(:_)時,我都必須重繪整個數組:
override func draw(_ rect: CGRect) {
strokeColor.setStroke()
for path in paths{
path.stroke()
}
realPath?.stroke()
temporaryPath?.stroke()
}
在繪制20條路徑后,這會造成性能問題。 有什么解決方案可以在每次調用draw(:_)時不重繪整個數組?
我得出的結論是,僅將要繪制的路徑的矩形傳遞給setNeedsDisplay(),再加上僅在touchesEnded(_ :)時才在數組中繪制線條的條件,這是一個不錯的解決方案。 但是,其他具有類似功能的應用程序顯然不會這樣做,因此我認為有更好的解決方案。
override func draw(_ rect: CGRect) {
strokeColor.setStroke()
realPath?.stroke()
if yesnewline == true{
for path in paths{
path.stroke()
}
yesnewline=false
}
temporaryPath?.stroke()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.