My code right here displays a red line on the top of the imagePicker when taking a photo. I want to do the same thing but add a image in the middle of the red line. See pic. I added the word image in a yellow box as a example of what I am trying to code.
@IBAction func takePhoto(_ sender: UIButton) {
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
let mainView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height-150))
let blockView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: 150))
blockView.backgroundColor = UIColor.red
mainView.addSubview(blockView)
imagePicker.cameraOverlayView = mainView
}
Just do:
let frame = CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: 150)
let blockView = UIImageView.init(frame: frame)
blockView.contentMode = .scaleAspectFit
blockView.image = UIImage(named: "NameOfYourImage") // Just an example.
See UIImageView
.
The frame
above needs adjustment of course, to allow for top and bottom margins you show in your screenshot.