CroppingParameters.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // CroppingParameters.swift
  3. // ALCameraViewController
  4. //
  5. // Created by Guillaume Bellut on 02/09/2017.
  6. // Copyright © 2017 zero. All rights reserved.
  7. //
  8. // Modified by Kevin Kieffer on 2019/08/06. Changes as follows:
  9. // Adding an aspectRatio for the cropping rectangle. Default is 1 (a square)
  10. import UIKit
  11. public struct CroppingParameters {
  12. /// Enable the cropping feature.
  13. /// Default value is set to false.
  14. let isEnabled: Bool
  15. /// Enable the overlay on the camera feature
  16. /// Default is set to true
  17. let cameraOverlay : Bool
  18. /// Allow the cropping area to be resized by the user.
  19. /// Default value is set to true.
  20. let allowResizing: Bool
  21. /// Allow the cropping area to be moved by the user.
  22. /// Default value is set to false.
  23. let allowMoving: Bool
  24. /// Allow rotating 90 degrees in the confirm view
  25. /// Default value is set to true
  26. let allowRotate: Bool
  27. /// Aspect ratio of the crop
  28. let aspectRatioHeightToWidth : CGFloat
  29. /// Prevent the user to resize the cropping area below a minimum size.
  30. /// Default value is (60, 60). Below this value, corner buttons will overlap.
  31. let minimumSize: CGSize
  32. /// The maximum scale factor the user can zoom in, default of 1
  33. let maximumZoom : CGFloat
  34. public init(isEnabled: Bool = false,
  35. allowResizing: Bool = true,
  36. allowMoving: Bool = true,
  37. allowRotate: Bool = true,
  38. minimumSize: CGSize = CGSize(width: 60, height: 60),
  39. aspectRatioHeightToWidth: CGFloat = 1.0,
  40. maximumZoom: CGFloat = 1.0,
  41. cameraOverlay : Bool = true) {
  42. self.isEnabled = isEnabled
  43. self.allowResizing = allowResizing
  44. self.allowMoving = allowMoving
  45. self.allowRotate = allowRotate
  46. self.minimumSize = minimumSize
  47. self.aspectRatioHeightToWidth = aspectRatioHeightToWidth
  48. self.maximumZoom = maximumZoom
  49. self.cameraOverlay = cameraOverlay
  50. }
  51. }