ios - How do I change the text of a UILabel between each animation of animateWithDuration with repeat? -


i have array words containing ["alice", "bob", "charles"] , uilabel label. want label repeatedly fade in , out, different word words each time. if put text-changing code inside animations block, doesn’t execute, though fading works expected (the completion block run when stops repetition):

label.alpha = 0  uiview.animatewithduration(4, delay: 0, options: .autoreverse | .repeat, animations: {     self.label.text = nextword()     self.label.alpha = 1 }, completion: {_ in     nslog("completed animation") }) 

what’s way fix this? thanks.

surely not elegant working solution:

@iboutlet weak var label: uilabel!  let words = ["is", "this", "what", "you", "want?"] var currentindex = -1  override func viewdidappear(animated: bool) {     super.viewdidappear(animated)     shownextword() }  func shownextword() {     if currentindex == words.count - 1 {         currentindex = -1     }      uiview.animatewithduration(1, delay: 1, options: uiviewanimationoptions(0), animations: { () -> void in         self.label.alpha = 0.0     }) { (_) -> void in         self.label.text = self.words[++self.currentindex]         uiview.animatewithduration(1, animations: { () -> void in             self.label.alpha = 1.0             }, completion: { (_) -> void in                 self.shownextword()         })     } } 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -