ios13,在暗模式下添加imagePickerView

时间:2019-07-18 02:38:33

标签: swift ios13 ios-darkmode

我需要在视图中添加imagePicker.view而不是显示它。

但是当出现图像选择器视图时,我在Darkmode中看到了白色背景。

这是一个错误吗?还是有办法解决?

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

0 个答案:

没有答案