我想在Swift 3中更改UISegmentedControl选定段的。我已经搜索了很多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
//
}
}
谢谢!