私はユーザーが何かを描くことができるビューで画面を作ろうとしています。私はそのようなコードでカスタムビューを作成しました:UISplitViewControllerの描画に奇妙なバグがあります
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
swiped = false
if let touch = touches.first {
lastPoint = touch.location(in: imageView)
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
swiped = true
if let touch = touches.first {
let currentPoint = touch.location(in: imageView)
drawLine(fromPoint: lastPoint, toPoint: currentPoint)
lastPoint = currentPoint
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if !swiped {
// draw a single point
drawLine(fromPoint: lastPoint, toPoint: lastPoint)
}
と私はビューがビューコントローラですべてが正常であることを示しているとき
func drawLine(fromPoint: CGPoint, toPoint: CGPoint) {
UIGraphicsBeginImageContext(imageView.frame.size)
let context = UIGraphicsGetCurrentContext()
imageView.image?.draw(in: CGRect(x: 0, y: 0, width: imageView.frame.size.width, height: imageView.frame.size.height))
context?.move(to: fromPoint)
context?.addLine(to: toPoint)
context?.setLineCap(.round)
context?.setLineWidth(lineWidth)
context?.setStrokeColor(lineColor.cgColor)
context?.strokePath()
imageView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
}
を描画機能:
が、私が示しますUISplitViewControllerの詳細ビューで、ユーザーは描画を続けますが、既に描画されたイメージの一部が移動してフェードアウトします。
私はそのような行動
は、誰もがそのことについてどんな考えを持っているされていますが生成されているもの見当がつかないウェブでどのようなバグは約何かを見つけることができませんか?
あなたがそのバグ再現できるサンプルプロジェクトです:スプリットビューコントローラの実際のプロジェクトだけでなく、マスタービューで、ところで https://github.com/fizzy871/DrawingBug
を、しかし、ナビゲーションバーは、それが動作することが判明すぎ
これはちょうど私のアプリ、クレイジーなものに起こりました。今、私はフレームサイズを切り捨て、それは正常に動作します。解り覚えておかなければならないでしょう。 –