1
votes

I've created an animation block using UIView animations - but the animation is triggered on the UITextView for every letter the player types (it's a typing game). The moment a new letter is typed, it instantly completes the previous character's animation - no overlap is possible. How would I allow for multiple animations to start and finish without interrupting each one?

Current animation block:

UIView.transitionWithView(textViewForPlayer, duration: 0.1, options: .BeginFromCurrentState | .TransitionCrossDissolve | .AllowAnimatedContent, animations: {
    self.textForPlayer.addAttribute(
        NSForegroundColorAttributeName,
        value: UIColor.clearColor(),
        range: nsRangeOfTextShown)
    self.textViewForPlayer.attributedText = self.textForPlayer
    }, completion: { finished in
        UIView.transitionWithView(self.textViewForPlayer, duration: 2.1, options: .BeginFromCurrentState | .TransitionCrossDissolve | .AllowAnimatedContent, animations: {
            self.textForPlayer.addAttribute(
                NSForegroundColorAttributeName,
                value: UIColor.greenColor(),
                range: nsRangeOfTextShown)
            self.textViewForPlayer.attributedText = self.textForPlayer
            }, completion: { finished in
        })
        println("FINISHED2")
    }
)
1

1 Answers

1
votes

If I understand you correctly, and you want each letter to finish its own animation regardless of whether the user has typed the next letter, I suggest that you make a separate view for each animated letter. Then, in the completion block for the letter, you remove the animated view and add the letter - statically - to the UITextView.