【发布时间】:2019-09-02 14:46:58
【问题描述】:
我有一个分段控件,选中时需要蓝色,未选中时需要白色。我在未选择时设置色调颜色时遇到问题,由于某种原因,它总是变成灰色。
这就是它的样子:
蓝色边框实际上是一个带有一些边框颜色的 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
没有成功。 :(
【问题讨论】:
标签: colors background uisegmentedcontrol