iosswiftanimationuiview

When animating view with UIView.animate other views are also needlessly animated


I'm wondering why views in my custom TableViewCells are affected by animation which should animate only 2 views in my floating pager (which is even not in TableView's view hierarchy..

UIView.animate(withDuration: 0.3) {
    self.stateIndicator.isHiddenInStackView = true
    self.loaderIndicator.isHiddenInStackView = false
}

When I comment out animation block everything stops animating.

Attached GIF describes everything (Blue views gets animated corner radius, badges 'flies in' instead of just appearing):

UIView.animate strange behavior

enter image description here

Any help or hint will be appreciated :).

Regards Tom.


Solution

  • Write the things which you don't want to animate in the block

      UIView.performWithoutAnimation {
         //Write your code here
      }