I need to remove the zoom slider in the camera screen.
This is my code:
import UIKit
extension UIImagePickerController {
class func sourceCameraModePhoto(_ delegate: UIImagePickerControllerDelegate & UINavigationControllerDelegate, overlayView: UIView) -> UIImagePickerController {
let picker = UIImagePickerController()
picker.sourceType = .camera
picker.cameraCaptureMode = .photo
picker.showsCameraControls = false
picker.view.addSubview(overlayView)
picker.delegate = delegate
return picker
}
I guess found the answer to this issue:
The zoom slider is a UISlider, if your imagePickerController's view property contains a UISlider down its subviews, you can set its alpha to zero. This issue happens if you upgrade to iOS10.
func subviews(_ view: UIView) -> [UIView] {
return view.subviews + view.subviews.flatMap { subviews($0) }
}
let myViews = subviews(imagePickerController.view)
for view in myViews {
if view is UISlider {
view.alpha = 0.0
}
}
I hope this helps.
Let me know if there is a better solution.
This will remove the zoom slider:
picker.view.isUserInteractionEnabled = false
And it's probably future proof too.
The above knocks out user interaction for the camera.
Here is what worked for me finally.
Add the cameraOverlay as a subview to the picker.
if let overlay = overlayViewController?.view {
imagePicker.view.addSubview(overlay)
}
showsCameraControls
should be set before the UIImageViewController
is loaded.
That means you could it in the initialization of a customized UIImageViewController
.
- (instancetype)init {
if (self = [super init]) {
self.showsCameraControls = false;
}
return self;
}