ios - 当为 appDelegate 中的所有 View 设置自定义 tintColor 时,更改特定 View 的色调颜色

标签 ios swift appdelegate

我正在尝试通过 Storyboard更改 segmentControl 上的 tintColor。但是,不幸的是,在我的 AppDelegate 中,我为我的应用程序中的所有 View 设置了默认的 tintColor

在 AppDelegate 中:

UIView.appearance().tintColor = .myCustomColor

这将始终覆盖我的所有其他更改。因此,例如,如果我通过 Storyboard或以编程方式在我的 segmentControl 上设置另一个 tintColor,它不会有任何影响。是否可以在不删除我在 appDelegate 中的代码的情况下解决这个问题?

最佳答案

要设置全局色调颜色但仍允许在控件或 View 中使用不同的色调,只需设置:

window?.tintColor = .myCustomColor

AppDelegateapplication(_:didFinishLaunchingWithOptions:) 函数中。

关于ios - 当为 appDelegate 中的所有 View 设置自定义 tintColor 时,更改特定 View 的色调颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53223596/

相关文章:

ios - 如何使 UIRefreshControl 变小?

ios - 在 iPad Air 上运行时应用程序的屏幕尺寸是多少?

iphone - 找不到 AppDelegate.m

ios - 添加SceneDelegate并更新Info.plist后黑屏

ios - iPhone registerForRemoteNotificationTypes 不会产生错误但不会触发提供设备 token 的委托(delegate)

iphone - UILongPressGestureRecognizer - 只识别最后一次按下

ios - 动画 block 在更新文本后重置为原始位置

ios - 为什么我的数据没有写入plist文件?

swift - 没有更多上下文的表达式类型是模棱两可的-Swift

ios - Swift - 显示来自外部摄像头的实时视频