我想在 Swift 3中更改UISegmentedControl选定段的tintColor. 我在 Objective-c中搜索了很多答案…… 这是我的代码: class ViewController:UIViewController{var segment:UISegmentedControloverride func viewDidLoad() {super
我在 Objective-c中搜索了很多答案……
这是我的代码:
class ViewController:UIViewController{
var segment:UISegmentedControl
override func viewDidLoad() {
super.viewDidLoad()
segment.insertSegment(withTitle: "AAA", at: 0, animated: true)
segment.insertSegment(withTitle: "BBB", at: 1, animated: true)
segment.insertSegment(withTitle: "CCC", at: 2, animated: true)
segment.addTarget(self, action: #selector(changeValue), for: .valueChanged)
segment.selectedSegmentIndex = 0
view.addSubview(segment)
}
func changeValue(sender:AnyObject) {
//I don't know how to do that change color when segment selected
//
}
}
谢谢!
以编程方式更改段的色调,segment.tintColor = UIColor.yellow
