diff --git a/README.md b/README.md index 24113010..06b3ce00 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ imagePickerController.imageLimit = 5 ##### Configuration -Configure text, colors and fonts by just overriding the static variables in the ImagePicker [configuration](https://github.com/hyperoslo/ImagePicker/blob/master/Source/Configuration.swift) struct. As an example: +Configure text, colors, fonts and camera features by just overriding the static variables in the ImagePicker [configuration](https://github.com/hyperoslo/ImagePicker/blob/master/Source/Configuration.swift) struct. As an example: ```swift Configuration.doneButtonTitle = "Finish" diff --git a/Source/Configuration.swift b/Source/Configuration.swift index bc9863d6..b3744ce4 100644 --- a/Source/Configuration.swift +++ b/Source/Configuration.swift @@ -32,6 +32,7 @@ public struct Configuration { public static var cellSpacing: CGFloat = 2 // MARK: Custom behaviour - - public static var collapseCollectionViewWhileShot: Bool = true + + public static var canRotateCamera: Bool = true + public static var collapseCollectionViewWhileShot: Bool = true } diff --git a/Source/Extensions/ConstraintsSetup.swift b/Source/Extensions/ConstraintsSetup.swift index ebbb7b99..522fd8ea 100644 --- a/Source/Extensions/ConstraintsSetup.swift +++ b/Source/Extensions/ConstraintsSetup.swift @@ -74,22 +74,24 @@ extension TopView { addConstraint(NSLayoutConstraint(item: flashButton, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 55)) + + if Configuration.canRotateCamera { + addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Right, + relatedBy: .Equal, toItem: self, attribute: .Right, + multiplier: 1, constant: Dimensions.rightOffset)) + + addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .CenterY, + relatedBy: .Equal, toItem: self, attribute: .CenterY, + multiplier: 1, constant: 0)) - addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Right, - relatedBy: .Equal, toItem: self, attribute: .Right, - multiplier: 1, constant: Dimensions.rightOffset)) - - addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .CenterY, - relatedBy: .Equal, toItem: self, attribute: .CenterY, - multiplier: 1, constant: 0)) - - addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Width, - relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, - multiplier: 1, constant: 55)) + addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Width, + relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, + multiplier: 1, constant: 55)) - addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Height, - relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, - multiplier: 1, constant: 55)) + addConstraint(NSLayoutConstraint(item: rotateCamera, attribute: .Height, + relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, + multiplier: 1, constant: 55)) + } } } diff --git a/Source/ImagePickerController.swift b/Source/ImagePickerController.swift index 3adcfe0f..974ee72b 100644 --- a/Source/ImagePickerController.swift +++ b/Source/ImagePickerController.swift @@ -262,7 +262,7 @@ public class ImagePickerController: UIViewController { bottomContainer.pickerButton.enabled = enabled bottomContainer.tapGestureRecognizer.enabled = enabled topView.flashButton.enabled = enabled - topView.rotateCamera.enabled = enabled + topView.rotateCamera.enabled = Configuration.canRotateCamera } } diff --git a/Source/TopView/TopView.swift b/Source/TopView/TopView.swift index 53bbfa41..05aa417f 100644 --- a/Source/TopView/TopView.swift +++ b/Source/TopView/TopView.swift @@ -46,8 +46,14 @@ class TopView: UIView { override init(frame: CGRect) { super.init(frame: frame) + + var buttons: [UIButton] = [flashButton] - for button in [flashButton, rotateCamera] { + if (Configuration.canRotateCamera) { + buttons.append(rotateCamera) + } + + for button in buttons { button.layer.shadowColor = UIColor.blackColor().CGColor button.layer.shadowOpacity = 0.5 button.layer.shadowOffset = CGSize(width: 0, height: 1)