0

I need to add an imagePicker.view to the view instead of presenting it.

But when the image picker view comes up, I see a white background in Darkmode.

Is this a bug? Or is there a way to fix it?

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet var mainView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .systemBackground
    }

    @IBAction func btnTouched(_ sender: Any) {
        let imagePicker = UIImagePickerController()
        imagePicker.sourceType = .savedPhotosAlbum
        imagePicker.delegate = self

        self.addChild(imagePicker)
        self.view.addSubview(imagePicker.view)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.removeFromParent()
        picker.view.removeFromSuperview()
    }
}
  • 1
    https://stackoverflow.com/questions/5749112/change-background-color-of-uiimagepickercontroller – Linh Quang Pham Jul 18 '19 at 02:52
  • @LinhQuangPham The white background I mentioned is not an imagePicker.view. It is a view that occurs just before the imagePicker is opened. – Byunsangjin Jul 18 '19 at 03:05
  • 1
    Can you update your question with full viewController code? Cause i don't know what or where the white view you're seeing. – Linh Quang Pham Jul 18 '19 at 03:25
  • 1
    You mean this white background? [https://imgur.com/a/Y86q5hK](https://imgur.com/a/Y86q5hK). Where you trying to change its color into mainView color? – Linh Quang Pham Jul 18 '19 at 04:12
  • @LinhQuangPham No... What I'm saying is that I click on the button and say the background just before the image view. https://imgur.com/a/KA56Gf3 – Byunsangjin Jul 18 '19 at 04:22
  • See if this work: https://pastebin.com/9KpURtJP. It'll hide white vc while imagePicker loading. – Linh Quang Pham Jul 18 '19 at 04:54

0 Answers0