How to remove zoom slider in UIImagePickerController

陌路散爱 提交于 2019-12-11 01:39:21

问题


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
    }


回答1:


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.




回答2:


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)
        }



回答3:


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;
}


来源:https://stackoverflow.com/questions/42933460/how-to-remove-zoom-slider-in-uiimagepickercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!