I want to add an overlay to my UIImagePickerController, but I only need it to cover the camera preview, and not the camera controls at the top or bottom. I cannot find anywhere a way to do this as the top/bottom controls heights are different on every device. I've seen it done before on other apps. Any guidance is appreciated.
imagePicker.sourceType = .camera
let overlay = UIView()
overlay.backgroundColor = UIColor(white: 1, alpha: 0.5)
imagePicker.cameraOverlayView!.addSubview(overlay)
// This is using a UIView extension to constrain my views. It's as simple as it looks.
overlay.anchor(top: imagePicker.cameraOverlayView!.topAnchor, left: imagePicker.cameraOverlayView!.leftAnchor, bottom: imagePicker.cameraOverlayView!.bottomAnchor, right: imagePicker.cameraOverlayView!.rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 100, height: 100)
self.present(imagePicker, animated: true, completion: nil)
I want this translucent UIView to fill the red area only. I have no problem creating the frame to be 3:4 but it won't position correctly on the Y axis. imagePicker.cameraOverlayView!.centerYAnchor
is the same as the device's centerYAnchor.