Standar custom animation doesn't work
iac0 opened this issue · 3 comments
Hi, i have downloaded the example app and i put as rootViewController of the window yours ExampleViewController where i put a simple square red view ( code above ). Nothings happen, why?
`
import UIKit
import Spruce
class ExampleViewController: UIViewController {
let animations: [StockAnimation]
var sortFunction: SortFunction?
var animationView: UIView? = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
var timer: Timer?
init(animations: [StockAnimation], nibName: String?) {
self.animations = [.fadeIn, .expand(.slightly)]
animationView?.isUserInteractionEnabled = true
super.init(nibName: nibName, bundle: nil)
animationView?.backgroundColor = .red
view.addSubview(animationView!)
view.frame = UIScreen.main.bounds
view.backgroundColor = .blue
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setup()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(prepareAnimation))
animationView?.addGestureRecognizer(tapGesture)
}
func setup() {
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
prepareAnimation()
}
func prepareAnimation() {
animationView?.spruce.prepare(with: animations)
timer?.invalidate()
timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(callAnimation), userInfo: nil, repeats: false)
}
func callAnimation() {
let animation = SpringAnimation(duration: 0.7)
DispatchQueue.main.async {
self.animationView?.spruce.animate(self.animations, animationType: animation)
}
}
}`
@iac0 So I would need a tad bit more context on the setup of your view to see exactly why nothing is happening. But some suggestions to look for, is your red view inside of the animationView
? This animationView
is being told to animate all of the subviews. If there are no subviews of the animationView
then nothing will happen. If that doesn't work then we can discuss more about the setup of your view layout to see if there is anything happening there.
@iac0 Any updates on this issue?