How to remove zoom slider in UIImagePickerControll

2019-07-14 03:43发布

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
    }

enter image description here

3条回答
The star\"
2楼-- · 2019-07-14 04:06

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;
}
查看更多
迷人小祖宗
3楼-- · 2019-07-14 04:16

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-07-14 04:16

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)
        }
查看更多
登录 后发表回答