From 9383443563771bac20f1cca8e339e6c78d1050c0 Mon Sep 17 00:00:00 2001 From: fl034 Date: Fri, 22 Feb 2019 17:52:58 +0100 Subject: [PATCH 1/2] Fix export drawing for cases where the origin of the frame was not .zero --- Sources/TouchDrawView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/TouchDrawView.swift b/Sources/TouchDrawView.swift index 40b169a..4962601 100644 --- a/Sources/TouchDrawView.swift +++ b/Sources/TouchDrawView.swift @@ -102,7 +102,7 @@ open class TouchDrawView: UIView { /// Exports the current drawing open func exportDrawing() -> UIImage { UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.main.scale) - imageView.image?.draw(in: imageView.frame) + imageView.image?.draw(in: imageView.bounds) let imageFromContext = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() @@ -271,7 +271,7 @@ fileprivate extension TouchDrawView { /// Begins the image context func beginImageContext() { - UIGraphicsBeginImageContextWithOptions(imageView.frame.size, false, UIScreen.main.scale) + UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.main.scale) } /// Ends image context and sets UIImage to what was on the context From bc9eb06d2581731e44b0539db6a8e3f2b0bad7a5 Mon Sep 17 00:00:00 2001 From: fl034 Date: Wed, 4 Dec 2019 15:22:23 +0100 Subject: [PATCH 2/2] Prevent drop down to dismiss gesture in modal presentations (iOS 13) --- Sources/TouchDrawView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/TouchDrawView.swift b/Sources/TouchDrawView.swift index 4962601..6d85889 100644 --- a/Sources/TouchDrawView.swift +++ b/Sources/TouchDrawView.swift @@ -221,6 +221,15 @@ open class TouchDrawView: UIView { extension TouchDrawView { + open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + // This prevents the drop down to dismiss gesture in modal presentations from iOS 13 on. + // See also: https://stackoverflow.com/questions/56718552/disable-gesture-to-pull-down-form-page-sheet-modal-presentation + if gestureRecognizer is UIPanGestureRecognizer { + return false + } + return true + } + /// Triggered when touches begin override open func touchesBegan(_ touches: Set, with event: UIEvent?) { if let touch = touches.first {