I have done a simple animation on a UIView
and it works the way I want to. But it stops working when I seperate the code. I have put the UIView
that should be animated into a containerView
and that containerView
is connected to the animationCode
class
. The "main" viewController
has it's seperate class
as well with buttons that trigger the animation.
From the main viewController
:
bottomTableView.rx.modelSelected(ModeButtons.self)
.subscribe(onNext: { [weak self] value in
switch value {
case .One:
self?.container.animationOne()
case .Two:
self?.container.animationTwo()
}
}).disposed(by: disposeBag)
And one of the animation functions:
func animationOne(){
UIView.animate(withDuration: 0.3, animations: {
self.downarrow?.alpha = 1.0
self.upArrow?.alpha = 1.0
self.leftLine?.frame.size.width = 10.0
self.rightLine?.frame.size.width = 10.0
self.rightLine?.frame.origin.x = self.animationView.frame.width - self.rightLine!.frame.width
self.upArrow?.frame = CGRect(x: self.animationView.frame.width - self.rightLine!.frame.width - self.upArrow!.frame.width - 5.0, y: (self.animationView.frame.height - self.upArrow!.frame.height) / 2, width: self.upArrow!.frame.width, height: self.upArrow!.frame.height)
self.downarrow?.frame = CGRect(x: self.leftLine!.frame.width + 5.0, y: (self.animationView.frame.height - self.upArrow!.frame.height) / 2, width: self.upArrow!.frame.width, height: self.upArrow!.frame.height)
})
}
Here's an image that might explain the setup better: Up to the left is the containerView
with the UIView
and below are the buttons
. Like I previously said. This worked fine when everything is in the same viewController
and class
. So why isn't the animation work now? What am I missing?