我正在使用 Xcode 8.1,快速 3.0
我有代码用 2 个控件分段它的工作
当我尝试添加 3 时,它不知道我的代码有什么问题
这一项与 2 个分段一起工作
@IBAction func showComponent(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 0 {
UIView.animate(withDuration: 0.0, animations: {
self.containerViewA.alpha = 1
self.containerViewB.alpha = 0
})
} else {
UIView.animate(withDuration: 0.0, animations: {
self.containerViewA.alpha = 0
self.containerViewB.alpha = 1
})
}
}
这个不适用于 3 Segmented
这里正在尝试使用 3x 分段控制的新代码;
@IBAction func showComponent(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 0 {
UIView.animate(withDuration: 0.5, animations: {
self.containerViewA.alpha = 1
self.containerViewB.alpha = 0
self.containerViewC.alpha = 0
})
UIView.animate(withDuration: 0.5, animations: {
self.containerViewA.alpha = 0
self.containerViewB.alpha = 1
self.containerViewC.alpha = 0
} else {
UIView.animate(withDuration: 0.5, animations: {
self.containerViewA.alpha = 0
self.containerViewB.alpha = 0
self.containerViewC.alpha = 1
})
}
}