swift - UISegmentedControl iOS 13 SelectedTint 默认颜色
问题描述
我想将默认值SelectedTintColor
从UISegmentControl
另一个视图匹配,但我无法从属性检查器中提供的默认系统*颜色中找到匹配的颜色。
背景似乎是,.quaternarySystemFill
但在明暗模式下都没有与所选颜色相匹配的颜色。
即使以这种方式设置颜色也不起作用,因为.selectedSegmentTintColor
返回nil
:
label.backgroundColor = segmentedControl.selectedSegmentTintColor
有谁知道正确的颜色或者我需要使用自定义颜色吗?
编辑2: 目前这条线有效,但也许有更好的方法?
label.backgroundColor = label.traitCollection.userInterfaceStyle == .light ? .white : .tertiaryLabel
解决方案
根据我对您问题的理解,您想更改与 UISegmentControl 色调相同的背景颜色。你需要做的只是使用这个:
label.backgroundColor = segmentedControl.tintColor
希望对你有帮助
推荐阅读
- javascript - p5.js中带有矩形的网格中的意外边框模式
- java - 如何将经过验证的用户输入传递给方法参数?
- mysql - mysql sub select很慢
- xamarin.android - xamarin.android 中资源目录的路径
- javascript - 在 React redux 对象的状态数组中,我无法更新它创建的状态错误在调度之间检测到状态突变
- azure - 如果未发送客户端,如何在 APIM 入站策略中获取/设置 Traceparent 标头?
- mysql - 错误代码:1815。内部错误:无法重置表中的 LSN:数据结构损坏
- java - 线程“主”org.openqa.selenium.WebDriverException 中的异常:等待驱动程序服务器启动超时
- reactjs - 如何在反应 direflow 应用程序中导入本地字体(woff)
- sql - 有没有办法缩短以下代码?