gpt4 book ai didi

uicolor - iOS13:如何在 Assets 目录中为提升的用户界面级别指定颜色

转载 作者:行者123 更新时间:2023-12-03 23:10:39 27 4
gpt4 key购买 nike

iOS 13 为我们带来 UIUserInterfaceLevel ,可以是 .base.elevated .系统似乎会自动调整提供给 UIView 的颜色。当在黑暗模式下使用升高的级别时。

但是,似乎没有办法手动指定.elevated颜色在 Assets 目录 ,或者是吗?

唯一的方法似乎是通过 the new UIColor constructor :

UIColor.init { (traits) -> UIColor in
traits.userInterfaceLevel == .elevated ? UIColor(named: "myColor-elevated")! : UIColor(named: "myColor")!
}

最佳答案

据我所知,没有办法用颜色 Assets 做到这一点。

当您使用系统背景和填充颜色时,iOS 会在较高级别时自动选择“下一个更高”的颜色,即 .systemBackground变成 .secondarySystemBackground , 等等。

关于uicolor - iOS13:如何在 Assets 目录中为提升的用户界面级别指定颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58026941/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com