Group Group Group Group Group Group Group Group Group

The Strange behavior for Chapter 21's Challenge : Additive animations


hi guys

I run App from answer for chapter 21’s challenges project (My configuration : Xcode 9.2,OS X 10.2.6) in Simulator(not try at real device),when I quickly switch tap "show more " and “show less” button,It’s appear some Strange behavior :


you can see in demo , the animations was gone and part of animations is not completed.

all the code in toggleShowMore function is :

@IBAction func toggleShowMore(_ sender: UIButton) {

    self.showsMore = !self.showsMore

    let animations = {
      self.widgetHeight.constant = self.showsMore ? 230 : 130
      if let tableView = self.tableView {

    let textTransition = {
      UIView.transition(with: sender, duration: 0.25, options: .transitionCrossDissolve,
        animations: {
          sender.setTitle(self.showsMore ? "Show Less" : "Show More", for: .normal)
        completion: nil
    if let toggleHeightAnimator = toggleHeightAnimator, toggleHeightAnimator.isRunning {
      toggleHeightAnimator.addAnimations(textTransition, delayFactor: 0.5)
    } else {
      let spring = UISpringTimingParameters(mass: 30, stiffness: 1000, damping: 300, initialVelocity:
      toggleHeightAnimator = UIViewPropertyAnimator(duration: 0.0, timingParameters: spring)
      toggleHeightAnimator?.addAnimations(textTransition, delayFactor: 0.5)

    widgetView.expanded = showsMore

Has anyone encountered this problem?
Is that some changed???or Am I out???
Thanks a lot! :wink:


hi @hopy,
Have you tried with the basic first, remove all extras just change the height without animation.
I am not sure from the gif if you are tapping the button immediately or with a delay.



closed #3

This topic was automatically closed after 166 days. New replies are no longer allowed.