ios - 来自 pod 的命名颜色仅使用浅色外观而不是深色

标签 ios swift xcode cocoapods ios13

我有一个私有(private) pods ,里面是我的 Assets 目录。有一个带有“任何外观”和“深色外观”值的命名颜色。在消耗 pod 的主项目中,我可以设置颜色 storyboard color selection

当我在深色和浅色之间切换界面样式时,它甚至在 Storyboard 中看起来都是正确的。问题是当我运行代码时,它只使用浅色外观,即使在深色模式下也是如此。更令人困惑的是,如果我通过代码设置颜色,例如 viewDidLoad它按预期工作。

let bundle = Bundle(for: PrivatePodClass.self)
let color = UIColor(named: "tableViewSectionHeader", in: bundle, compatibleWith: nil)
// Works
view.backgroundColor = color

我不确定这是 XCode 11 的问题还是 cocoapods 的问题,但如果我不需要,我不想被迫通过代码设置颜色。

最佳答案

contentView.backgroundColor = UIColor(named: "redColor", in: nibBundle, compatibleWith: nil)
替换 bundlenibBundle .它对我有用。
enter image description here

关于ios - 来自 pod 的命名颜色仅使用浅色外观而不是深色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56794683/

相关文章:

ios - 检测 iPhone 何时连接到任何配对的汽车

ios - NSNotificationCreation 会影响应用程序性能吗?

ios - 带图像的按钮,点击按钮时图像消失 iOS 10

swift - 无法使用 int 参数列表调用 avgArray

ios - Xcode Bots 配置文件的位置

iphone - Xcode 4.2。运行时卡住 "Attaching to myapp"

ios - cocoa bean : List all versions of a pod ever released and see version history

iPhone - 以编程方式更改应用程序设置

ios - 如何使用 CocoaPods 正确安装 ReactiveCocoa?

swift 3 : [String: AnyObject] using NSCoding protocol to save with NSUserDefaults