func drawLines(fromPoint:CGPoint, toPoint: CGPoint){
if DrawingActive == true{
UIGraphicsBeginImageContext(self.view.frame.size)
ImageView.image?.draw(in: CGRect(x: 0, y: 0, width: ImageView.frame.width, height: ImageView.frame.height))
let context = UIGraphicsGetCurrentContext()
context?.move(to: CGPoint(x: fromPoint.x, y: fromPoint.y))
context?.addLine(to: CGPoint(x: toPoint.x, y: toPoint.y))
context?.setBlendMode(CGBlendMode.normal)
context?.setLineCap(CGLineCap.round)
context?.setLineWidth(fontSizeOfDraw)
context?.setStrokeColor(DrawingColor.cgColor)
context?.strokePath()
ImageView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
PickSize.isEnabled = false
PickSize.alpha = 0
ColorPickerController.isEnabled = false
ColorPickerController.alpha = 0
DrawBtn.isEnabled = false
DrawBtn.alpha = 0
SelectButton.isEnabled = false
SelectButton.alpha = 0
}
}
func slideDown(fromPoint:CGPoint, toPoint: CGPoint){
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
swiped = true
if let touch = touches.first{
let currentPoint = touch.location(in: self.view)
drawLines(fromPoint: lastPoint, toPoint: currentPoint)
lastPoint = currentPoint
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if !swiped{
}
drawLines(fromPoint: lastPoint, toPoint: lastPoint)
PickSize.isEnabled = true
PickSize.alpha = 1
ColorPickerController.isEnabled = true
ColorPickerController.alpha = 1
DrawBtn.isEnabled = true
DrawBtn.alpha = 1
SelectButton.isEnabled = true
SelectButton.alpha = 0.75
}Hello I have this code, my Problem is, that if i try to draw on an image (ImageView) the imageview gets stretched