0
am en utilisant Xcode 8.1, rapide 3.0contrôle 3 Segmenté
j'ai le code segmenté son travail avec 2 contrôle
lorsque je tente d'ajouter 3 sa ne fonctionne pas une idée qui ne va pas avec mon code
celui-travail avec 2 segmentée
@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
})
}
}
celui-ci ne fonctionne pas avec 3 segmentée
ici essaye le nouveau code avec le contrôle segmenté 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
})
}
}