diff --git a/Example/ExampleCropViewController.swift b/Example/ExampleCropViewController.swift
index 3b03158..4e2e679 100644
--- a/Example/ExampleCropViewController.swift
+++ b/Example/ExampleCropViewController.swift
@@ -30,19 +30,13 @@ class ExampleCropViewController: IGRPhotoTweakViewController {
super.viewDidLoad()
//FIXME: Themes Preview
- //IGRCropLine.appearance().backgroundColor = UIColor.green
- //IGRCropGridLine.appearance().backgroundColor = UIColor.yellow
- //IGRCropCornerView.appearance().backgroundColor = UIColor.purple
- //IGRCropCornerLine.appearance().backgroundColor = UIColor.orange
- //IGRCropMaskView.appearance().backgroundColor = UIColor.blue
- //IGRPhotoContentView.appearance().backgroundColor = UIColor.gray
- //IGRPhotoTweakView.appearance().backgroundColor = UIColor.brown
-
- //FIXME: Customization
- //self.photoView.isHighlightMask = true
- //self.photoView.highlightMaskAlphaValue = 0.2
- //self.maxRotationAngle = CGFloat(M_PI)
- //self.isAutoSaveToLibray = true
+// IGRCropLine.appearance().backgroundColor = UIColor.green
+// IGRCropGridLine.appearance().backgroundColor = UIColor.yellow
+// IGRCropCornerView.appearance().backgroundColor = UIColor.purple
+// IGRCropCornerLine.appearance().backgroundColor = UIColor.orange
+// IGRCropMaskView.appearance().backgroundColor = UIColor.blue
+// IGRPhotoContentView.appearance().backgroundColor = UIColor.gray
+// IGRPhotoTweakView.appearance().backgroundColor = UIColor.brown
self.setupSlider()
}
@@ -135,21 +129,29 @@ class ExampleCropViewController: IGRPhotoTweakViewController {
}
//FIXME: Themes Preview
-// override func borderColor() -> UIColor {
+// override open func customBorderColor() -> UIColor {
// return UIColor.red
// }
//
-// override func borderWidth() -> CGFloat {
+// override open func customBorderWidth() -> CGFloat {
// return 2.0
// }
//
-// override func cornerBorderWidth() -> CGFloat {
+// override open func customCornerBorderWidth() -> CGFloat {
// return 4.0
// }
//
-// override func cornerBorderLength() -> CGFloat {
+// override open func customCornerBorderLength() -> CGFloat {
// return 30.0
// }
+//
+// override open func customIsHighlightMask() -> Bool {
+// return true
+// }
+//
+// override open func customHighlightMaskAlphaValue() -> CGFloat {
+// return 0.3
+// }
}
extension ExampleCropViewController: KCHorizontalDialDelegate {
diff --git a/Example/Resources/Base.lproj/Main.storyboard b/Example/Resources/Base.lproj/Main.storyboard
index 7688509..f3a3d8c 100644
--- a/Example/Resources/Base.lproj/Main.storyboard
+++ b/Example/Resources/Base.lproj/Main.storyboard
@@ -134,7 +134,7 @@
-
+
diff --git a/IGRPhotoTweaks.podspec b/IGRPhotoTweaks.podspec
index a244fff..4e6b9a5 100755
--- a/IGRPhotoTweaks.podspec
+++ b/IGRPhotoTweaks.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'IGRPhotoTweaks'
- spec.version = '1.0.1'
+ spec.version = '1.0.2'
spec.platform = :ios, '9.0'
spec.license = { :type => "MIT", :file => "LICENSE" }
diff --git a/IGRPhotoTweaks/CropView/IGRCropCornerLine.swift b/IGRPhotoTweaks/CropView/IGRCropCornerLine.swift
index 3742dd6..a194c42 100644
--- a/IGRPhotoTweaks/CropView/IGRCropCornerLine.swift
+++ b/IGRPhotoTweaks/CropView/IGRCropCornerLine.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRCropCornerLine: UIView {
+@objc public class IGRCropCornerLine: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.cropLine()
}
diff --git a/IGRPhotoTweaks/CropView/IGRCropCornerView.swift b/IGRPhotoTweaks/CropView/IGRCropCornerView.swift
index 2ac1402..84bc3f9 100644
--- a/IGRPhotoTweaks/CropView/IGRCropCornerView.swift
+++ b/IGRPhotoTweaks/CropView/IGRCropCornerView.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRCropCornerView: UIView {
+@objc public class IGRCropCornerView: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.clear
}
@@ -20,7 +20,7 @@ class IGRCropCornerView: UIView {
setup(cornerType: type, lineWidth: lineWidth, lineLenght:lineLenght)
}
- required init?(coder aDecoder: NSCoder) {
+ required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup(cornerType: .upperRight, lineWidth: 2.0, lineLenght:kCropViewCornerLength)
diff --git a/IGRPhotoTweaks/CropView/IGRCropGridLine.swift b/IGRPhotoTweaks/CropView/IGRCropGridLine.swift
index 2f0179c..4f6e563 100644
--- a/IGRPhotoTweaks/CropView/IGRCropGridLine.swift
+++ b/IGRPhotoTweaks/CropView/IGRCropGridLine.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRCropGridLine: UIView {
+@objc public class IGRCropGridLine: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.gridLine()
}
diff --git a/IGRPhotoTweaks/CropView/IGRCropLine.swift b/IGRPhotoTweaks/CropView/IGRCropLine.swift
index f845595..6de8c0c 100644
--- a/IGRPhotoTweaks/CropView/IGRCropLine.swift
+++ b/IGRPhotoTweaks/CropView/IGRCropLine.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRCropLine: UIView {
+@objc public class IGRCropLine: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.cropLine()
}
diff --git a/IGRPhotoTweaks/CropView/IGRCropMaskView.swift b/IGRPhotoTweaks/CropView/IGRCropMaskView.swift
index 824d06f..1ef8d19 100644
--- a/IGRPhotoTweaks/CropView/IGRCropMaskView.swift
+++ b/IGRPhotoTweaks/CropView/IGRCropMaskView.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRCropMaskView: UIView {
+@objc public class IGRCropMaskView: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.mask()
}
diff --git a/IGRPhotoTweaks/CropView/IGRPhotoContentView.swift b/IGRPhotoTweaks/CropView/IGRPhotoContentView.swift
index a489c0f..aa8b988 100644
--- a/IGRPhotoTweaks/CropView/IGRPhotoContentView.swift
+++ b/IGRPhotoTweaks/CropView/IGRPhotoContentView.swift
@@ -8,9 +8,9 @@
import UIKit
-class IGRPhotoContentView: UIView {
+@objc public class IGRPhotoContentView: UIView {
- override class func initialize () {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.clear
}
@@ -31,7 +31,7 @@ class IGRPhotoContentView: UIView {
}
}
- override func layoutSubviews() {
+ override public func layoutSubviews() {
super.layoutSubviews()
self.imageView?.frame = self.bounds
}
diff --git a/IGRPhotoTweaks/IGRPhotoTweakView.swift b/IGRPhotoTweaks/IGRPhotoTweakView.swift
index 3ffaa0d..38b814d 100644
--- a/IGRPhotoTweaks/IGRPhotoTweakView.swift
+++ b/IGRPhotoTweaks/IGRPhotoTweakView.swift
@@ -8,7 +8,7 @@
import UIKit
-protocol IGRPhotoTweakViewCustomizationDelegate: NSObjectProtocol {
+@objc public protocol IGRPhotoTweakViewCustomizationDelegate: NSObjectProtocol {
func borderColor() -> UIColor
func borderWidth() -> CGFloat
@@ -16,18 +16,18 @@ protocol IGRPhotoTweakViewCustomizationDelegate: NSObjectProtocol {
func cornerBorderWidth() -> CGFloat
func cornerBorderLength() -> CGFloat
+
+ func isHighlightMask() -> Bool
+ func highlightMaskAlphaValue() -> CGFloat
}
-class IGRPhotoTweakView: UIView {
- override class func initialize () {
+@objc public class IGRPhotoTweakView: UIView {
+ override public class func initialize () {
self.appearance().backgroundColor = UIColor.photoTweakCanvasBackground()
}
open weak var customizationDelegate: IGRPhotoTweakViewCustomizationDelegate?
- var isHighlightMask: Bool = false
- var highlightMaskAlphaValue: CGFloat = 0.5
-
private(set) var angle: CGFloat = 0.0
private(set) var photoContentOffset = CGPoint.zero
private(set) var cropView: IGRCropView!
@@ -66,6 +66,7 @@ class IGRPhotoTweakView: UIView {
super.init(frame: frame)
self.image = image
+
self.customizationDelegate = customizationDelegate
// scale the image
@@ -82,7 +83,6 @@ class IGRPhotoTweakView: UIView {
self.centerY = self.maximumCanvasSize.height / 2.0 + kCanvasHeaderHeigth
self.scrollView = IGRPhotoScrollView(frame: bounds)
- self.scrollView.updateDelegate = self
self.scrollView.center = CGPoint(x: (self.frame.width / 2.0), y: self.centerY)
self.scrollView.bounces = true
self.scrollView.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
@@ -96,6 +96,7 @@ class IGRPhotoTweakView: UIView {
self.scrollView.clipsToBounds = false
self.scrollView.contentSize = CGSize(width: self.scrollView.bounds.size.width,
height: self.scrollView.bounds.size.height)
+ self.scrollView.updateDelegate = self
self.addSubview(self.scrollView)
self.photoContentView = IGRPhotoContentView(frame: self.scrollView.bounds)
@@ -146,11 +147,19 @@ class IGRPhotoTweakView: UIView {
return (self.customizationDelegate?.cornerBorderLength())!
}
- required init?(coder aDecoder: NSCoder) {
+ func isHighlightMask() -> Bool {
+ return (self.customizationDelegate?.isHighlightMask())!
+ }
+
+ func highlightMaskAlphaValue() -> CGFloat {
+ return (self.customizationDelegate?.highlightMaskAlphaValue())!
+ }
+
+ required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
- override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
+ override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if self.cropView.frame.insetBy(dx: -kCropViewHotArea, dy: -kCropViewHotArea).contains(point) &&
!self.cropView.frame.insetBy(dx: kCropViewHotArea, dy: kCropViewHotArea).contains(point) {
@@ -188,8 +197,8 @@ class IGRPhotoTweakView: UIView {
}
fileprivate func highlightMask(_ highlight:Bool, animate: Bool) {
- if isHighlightMask {
- let newAlphaValue: CGFloat = highlight ? highlightMaskAlphaValue : 1.0
+ if (self.isHighlightMask()) {
+ let newAlphaValue: CGFloat = highlight ? self.highlightMaskAlphaValue() : 1.0
let animationBlock: ((_: Void) -> Void)? = {(_: Void) -> Void in
self.topMask.alpha = newAlphaValue
@@ -301,15 +310,15 @@ class IGRPhotoTweakView: UIView {
}
extension IGRPhotoTweakView : UIScrollViewDelegate {
- func viewForZooming(in scrollView: UIScrollView) -> UIView? {
+ public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.photoContentView
}
- func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
+ public func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
self.cropView.updateCropLines(true)
}
- func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
+ public func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
self.manualZoomed = true
self.cropView.dismissCropLines()
}
diff --git a/IGRPhotoTweaks/IGRPhotoTweakViewController.swift b/IGRPhotoTweaks/IGRPhotoTweakViewController.swift
index 1a28e3c..9f83a04 100644
--- a/IGRPhotoTweaks/IGRPhotoTweakViewController.swift
+++ b/IGRPhotoTweaks/IGRPhotoTweakViewController.swift
@@ -235,22 +235,54 @@ import Photos
present(ac, animated: true, completion: nil)
}
}
-}
-
-extension IGRPhotoTweakViewController : IGRPhotoTweakViewCustomizationDelegate {
- func borderColor() -> UIColor {
+
+ open func customBorderColor() -> UIColor {
return UIColor.cropLine()
}
- func borderWidth() -> CGFloat {
+ open func customBorderWidth() -> CGFloat {
return 1.0
}
- func cornerBorderWidth() -> CGFloat {
+ open func customCornerBorderWidth() -> CGFloat {
return kCropViewCornerWidth
}
- func cornerBorderLength() -> CGFloat {
+ open func customCornerBorderLength() -> CGFloat {
return kCropViewCornerLength
}
+
+ open func customIsHighlightMask() -> Bool {
+ return true
+ }
+
+ open func customHighlightMaskAlphaValue() -> CGFloat {
+ return 0.3
+ }
+}
+
+extension IGRPhotoTweakViewController : IGRPhotoTweakViewCustomizationDelegate {
+ public func borderColor() -> UIColor {
+ return self.customBorderColor()
+ }
+
+ public func borderWidth() -> CGFloat {
+ return self.customBorderWidth()
+ }
+
+ public func cornerBorderWidth() -> CGFloat {
+ return self.customCornerBorderWidth()
+ }
+
+ public func cornerBorderLength() -> CGFloat {
+ return self.customCornerBorderLength()
+ }
+
+ public func isHighlightMask() -> Bool {
+ return self.customIsHighlightMask()
+ }
+
+ public func highlightMaskAlphaValue() -> CGFloat {
+ return self.customHighlightMaskAlphaValue()
+ }
}