diff --git a/.gitignore b/.gitignore index 8b09e7e..8288931 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Carthage/Build # Swift Package Manager .build/ +.DS_Store \ No newline at end of file diff --git a/Demo/TouchDrawDemo.xcodeproj/project.pbxproj b/Demo/TouchDrawDemo.xcodeproj/project.pbxproj index 2075768..62b1aee 100644 --- a/Demo/TouchDrawDemo.xcodeproj/project.pbxproj +++ b/Demo/TouchDrawDemo.xcodeproj/project.pbxproj @@ -136,7 +136,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Christian Paul Dehli"; TargetAttributes = { EE43D46C1A14A6F200311C06 = { @@ -274,12 +274,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -326,12 +328,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/Demo/TouchDrawDemo.xcodeproj/xcshareddata/xcschemes/TouchDrawDemo.xcscheme b/Demo/TouchDrawDemo.xcodeproj/xcshareddata/xcschemes/TouchDrawDemo.xcscheme index 26379be..b913952 100644 --- a/Demo/TouchDrawDemo.xcodeproj/xcshareddata/xcschemes/TouchDrawDemo.xcscheme +++ b/Demo/TouchDrawDemo.xcodeproj/xcshareddata/xcschemes/TouchDrawDemo.xcscheme @@ -1,6 +1,6 @@ UIImage { - UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.main.scale) - imageView.image?.draw(in: imageView.frame) + UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.main.scale) + self.image?.draw(in: frame) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image! @@ -213,6 +178,11 @@ open class TouchDrawView: UIView { redrawStack() touchDrawUndoManager.registerUndo(withTarget: self, selector: #selector(clearDrawing), object: nil) } + + open override func layoutSubviews() { + super.layoutSubviews() + redrawStack() + } } // MARK: - Touch Actions @@ -269,18 +239,18 @@ fileprivate extension TouchDrawView { /// Begins the image context func beginImageContext() { - UIGraphicsBeginImageContextWithOptions(self.imageView.frame.size, false, UIScreen.main.scale) + UIGraphicsBeginImageContextWithOptions(frame.size, false, UIScreen.main.scale) } /// Ends image context and sets UIImage to what was on the context func endImageContext() { - imageView.image = UIGraphicsGetImageFromCurrentImageContext() + image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() } /// Draws the current image for context func drawCurrentImage() { - imageView.image?.draw(in: imageView.bounds) + image?.draw(in: bounds) } /// Clears view, then draws stack diff --git a/TouchDraw.xcodeproj/project.pbxproj b/TouchDraw.xcodeproj/project.pbxproj index 932c8a1..02f1881 100644 --- a/TouchDraw.xcodeproj/project.pbxproj +++ b/TouchDraw.xcodeproj/project.pbxproj @@ -160,7 +160,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Christian Paul Dehli"; TargetAttributes = { 89EADBB31CB87C23001130A8 = { @@ -278,12 +278,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -334,12 +336,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/TouchDraw.xcodeproj/xcshareddata/xcschemes/TouchDraw.xcscheme b/TouchDraw.xcodeproj/xcshareddata/xcschemes/TouchDraw.xcscheme index 45367a2..518143a 100644 --- a/TouchDraw.xcodeproj/xcshareddata/xcschemes/TouchDraw.xcscheme +++ b/TouchDraw.xcodeproj/xcshareddata/xcschemes/TouchDraw.xcscheme @@ -1,6 +1,6 @@