0
我有这个UISegmentControl三段,我按其中之一,它突出显示。然后我按下一个按钮来隐藏UISegmentControl,当我回到UISegmentControl时,我按下的最后一个段不再被高亮显示。我将如何解决这个问题?如何让UISegmentControl中的最后一个被触摸的段在Swift中高亮显示?
func pressSettingsButton() {
var customSC = UISegmentedControl()
let items = ["blue", "orange", "red"]
customSC = UISegmentedControl(items: items)
customSC.selectedSegmentIndex = 0
customSC.frame = (CGRectMake(self.view!.bounds.width/2 - 540/2, 65 * scaleFactor, 250, 30))
customSC.layer.cornerRadius = 5.0
customSC.backgroundColor = UIColor.blackColor()
customSC.tintColor = UIColor.whiteColor()
customSC.addTarget(self, action: #selector(GameScene.changeColor(_:)), forControlEvents: .ValueChanged)
self.view!.addSubview(customSC)
}
if node.name == "settings" {
//shows UISegmentControl
pressSettingsButton()
}
if node.name == "closesettings" {
//close segment control
customSC.hidden = true
}