/ iOS

Fix animations in Eureka

Recently I'm using Eureka for building forms dynamically. I show or hide some rows based on API data and the animation is strange, I couldn't find a way to disable it with Eureka APIs for aniamtion customization. But in the end I found two ways to solve this problem.

  1. Use a screenshot to hide the animations
// Use screenshot to hide strange animation of Eureka form
let window = UIApplication.shared.keyWindow!
let view = window.snapshotView(afterScreenUpdates: true)
if let view = view {
    window.addSubview(view)
}

// Hide or show rows

DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
    UIView.transition(with: window, duration: 0.25, options: .transitionCrossDissolve, animations: {
        view?.removeFromSuperview()
    }, completion: nil)
})
  1. Disable UIView animations
UIView.setAnimationsEnabled(false)
// Hide or show rows
UIView.setAnimationsEnabled(true)
Fix animations in Eureka
Share this