我需要在视图中添加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()
}
}