diff --git a/Sources/Mantis/CropView/CropAuxiliaryIndicatorView.swift b/Sources/Mantis/CropView/CropAuxiliaryIndicatorView.swift index 4dd50e4f..c9aa06aa 100644 --- a/Sources/Mantis/CropView/CropAuxiliaryIndicatorView.swift +++ b/Sources/Mantis/CropView/CropAuxiliaryIndicatorView.swift @@ -22,6 +22,7 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc private var gridMainColor = UIColor.white private var gridSecondaryColor = UIColor.lightGray private var disableCropBoxDeformation = false + private var style: CropAuxiliaryIndicatorStyleType = .normal var cropBoxHotAreaUnit: CGFloat = 42 @@ -48,12 +49,16 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc } } - init(frame: CGRect, cropBoxHotAreaUnit: CGFloat, disableCropBoxDeformation: Bool = false) { + init(frame: CGRect, + cropBoxHotAreaUnit: CGFloat, + disableCropBoxDeformation: Bool = false, + style: CropAuxiliaryIndicatorStyleType = .normal) { super.init(frame: frame) clipsToBounds = false backgroundColor = .clear self.cropBoxHotAreaUnit = cropBoxHotAreaUnit self.disableCropBoxDeformation = disableCropBoxDeformation + self.style = style setup() } @@ -65,7 +70,11 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc private func createNewLine() -> UIView { let view = UIView() view.frame = .zero - view.backgroundColor = .white + if style == .normal { + view.backgroundColor = .white + } else { + view.backgroundColor = .clear + } addSubview(view) return view } @@ -74,7 +83,14 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc borderLine = createNewLine() borderLine.layer.backgroundColor = UIColor.clear.cgColor borderLine.layer.borderWidth = borderThickness - borderLine.layer.borderColor = boarderNormalColor.cgColor + + if style == .normal { + borderLine.layer.borderColor = boarderNormalColor.cgColor + hintLine.backgroundColor = boarderHintColor + } else { + borderLine.layer.borderColor = UIColor.clear.cgColor + hintLine.backgroundColor = .clear + } for _ in 0..<8 { cornerHandles.append(createNewLine()) @@ -84,8 +100,6 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc edgeLineHandles.append(createNewLine()) } - hintLine.backgroundColor = boarderHintColor - setupAccessibilityHelperViews() } @@ -109,6 +123,10 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc } override func draw(_ rect: CGRect) { + if style == .transparent { + return + } + if !gridHidden { let indicatorLineNumber = gridLineNumberType.getIndicatorLineNumber() @@ -158,7 +176,11 @@ final class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtoc height: bounds.height + 2 * borderThickness) borderLine.layer.backgroundColor = UIColor.clear.cgColor borderLine.layer.borderWidth = borderThickness - borderLine.layer.borderColor = boarderNormalColor.cgColor + if style == .normal { + borderLine.layer.borderColor = boarderNormalColor.cgColor + } else { + borderLine.layer.borderColor = UIColor.clear.cgColor + } } private func layoutCornerHandles() { diff --git a/Sources/Mantis/CropViewConfig.swift b/Sources/Mantis/CropViewConfig.swift index 4c1f0fd8..464d8a10 100644 --- a/Sources/Mantis/CropViewConfig.swift +++ b/Sources/Mantis/CropViewConfig.swift @@ -31,6 +31,8 @@ public struct CropViewConfig { public var cropMaskVisualEffectType: CropMaskVisualEffectType = .blurDark + public var cropAuxiliaryIndicatorStyle: CropAuxiliaryIndicatorStyleType = .normal + public var presetTransformationType: PresetTransformationType = .none public var minimumZoomScale: CGFloat = 1 { diff --git a/Sources/Mantis/Enum.swift b/Sources/Mantis/Enum.swift index b4a2030a..89d2d727 100644 --- a/Sources/Mantis/Enum.swift +++ b/Sources/Mantis/Enum.swift @@ -146,6 +146,11 @@ enum RotateBy90DegreeType { } } +public enum CropAuxiliaryIndicatorStyleType { + case normal + case transparent +} + enum CropViewAuxiliaryIndicatorHandleType: Int { case none case topLeft diff --git a/Sources/Mantis/Mantis.swift b/Sources/Mantis/Mantis.swift index 284742fe..33926e97 100644 --- a/Sources/Mantis/Mantis.swift +++ b/Sources/Mantis/Mantis.swift @@ -98,7 +98,8 @@ private func buildCropView(withImage image: UIImage, rotationControlView: RotationControlViewProtocol?) -> CropViewProtocol { let cropAuxiliaryIndicatorView = CropAuxiliaryIndicatorView(frame: .zero, cropBoxHotAreaUnit: cropViewConfig.cropBoxHotAreaUnit, - disableCropBoxDeformation: cropViewConfig.disableCropBoxDeformation) + disableCropBoxDeformation: cropViewConfig.disableCropBoxDeformation, + style: cropViewConfig.cropAuxiliaryIndicatorStyle) let imageContainer = ImageContainer(image: image) let cropView = CropView(image: image, cropViewConfig: cropViewConfig,