更改 UIImagePickerController 栏颜色

问题描述 投票:0回答:1

我正在努力更改

UIImagePickerController
库类型的颜色。有人知道我做错了什么吗?不知道为什么它是黄色的,我只是想让它看起来更标准。

代码

private func getImage(fromSourceType sourceType: UIImagePickerController.SourceType) {

    if UIImagePickerController.isSourceTypeAvailable(sourceType) {

        let imagePickerController = UIImagePickerController()
        imagePickerController.navigationBar.isTranslucent = false
        imagePickerController.navigationBar.barTintColor = .white
        imagePickerController.navigationBar.tintColor = .black
        imagePickerController.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
        imagePickerController.delegate = self
        imagePickerController.sourceType = sourceType
        self.parentViewController?.present(imagePickerController, animated: true, completion: nil)
    }
}

结果

ios swift uiimagepickercontroller
1个回答
0
投票

你检查过你的AppDelegate.swift吗?

如果你在 AppDelegate 中自定义了 UINavigationBar barTintColor,它也会影响 UIImagePicker 的 barTintColor:

UINavigationBar.appearance().barTintColor = UIColor(named: "yellow")

检查是否有类似上面的代码,删除它,barTintColor就会恢复默认颜色。

© www.soinside.com 2019 - 2024. All rights reserved.