colors - IOS中分段控制的背景颜色
问题描述
我有一个分段控件,选中时需要为蓝色,未选中时需要为白色。我在未选择时设置色调颜色时遇到问题,由于某种原因,它总是变成灰色。
这是它的样子:
蓝色边框实际上是一个带有一些边框颜色的 UIView,我在其中粘贴了分段控件。但我不能改变灰色背景(应该是白色的)。
我试着做所有这些:
sc.selectedSegmentTintColor = UIColor.blue
sc.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body),NSAttributedString.Key.foregroundColor: UIColor.white], for: .selected)
sc.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body),NSAttributedString.Key.foregroundColor: UIColor.blue], for: .normal)
sc.tintColor = .white
sc.backgroundColor = .white
sc.isOpaque = true
没有成功。:(
解决方案
它与背景颜色一起工作正常
self.backgroundColor = .red
它在 iOS 13 中运行良好
推荐阅读
- sql - 在 SQL Server 中发送带有 CSV 附件的电子邮件(SQL 作业失败)
- javascript - 如何计算产品应该出现在哪个页面上?
- angular - Angular 私有内部接口(又名 Typescript 嵌套类)
- angular - 在 ngOnInit() 中设置会话存储中的 API 响应
- terraform - 从模块 terraform 导入变量
- xml - SSIS 从 Schema 和 Excel 生成 XML
- json - 如何访问邮递员测试的响应正文中的信息获取呼叫
- javascript - 循环获取,保持结果顺序
- docker - 运行气流 initdb 时发送到 create_engine() 的无效参数“pool_pre_ping”
- rust - 线程“主”在“盒子”处惊慌失措
'