2

I have a subview including GMSMapView in my controller - initially it's collapsed and takes just a part of screen - then a user can expand it and see the map in fullscreen mode. The code below works however there is a strange flicker at the end of the animation Here is my code:

 let screenHeight = screenSize.height
    let proportionalHeight = (screenSize.width * 46.0 ) / 75.0
    mapViewHeight.constant = !isMapFullscreen ? screenHeight : proportionalHeight

    UIView.animate(withDuration: 1.0, delay: 0,
                   usingSpringWithDamping: 0.9,
                   initialSpringVelocity: 0,
                   options: UIViewAnimationOptions.curveEaseInOut,
                   animations: {
                    self.view.layoutIfNeeded()

    },
    completion: { finished in
                  if finished {
                      self.isMapFullscreen = !self.isMapFullscreen 
                  }
    })

video

Magda
  • 81
  • 1
  • 5

1 Answers1

1

It's almost two years later, but here it goes:

As this bug was not solved, we can at least suppress it by using CATransaction. The idea is to disable the animation (bug) after your main animation has completed.

Example:

CATransaction.begin()
UIView.animate(...,
               animations: { ... },
completion: { finished in
              if finished {
                  ...
                  CATransaction.setDisableActions(true)
              }
})
CATransaction.commit()