【发布时间】:2020-05-08 05:29:34
【问题描述】:
我在UIView 上做了一个简单的动画,它按我想要的方式工作。但是当我分离代码时它停止工作。我已将应该动画的UIView 放入containerView 中,并且containerView 连接到animationCode class。 “主要”viewController 具有独立的class 以及触发动画的按钮。
来自主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)
还有一个动画功能:
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)
})
}
下面的图片可以更好地解释设置:左边是containerView 和UIView,下面是buttons。就像我之前说的。当一切都在同一个viewController 和class 中时,这工作得很好。那么为什么动画现在不工作了?我错过了什么?
【问题讨论】:
-
animationOne这个函数被调用了? -
是的,它贯穿了整个事情,但没有动画显示......
-
请发布更多代码....或检查网点..您的图像在容器中还是按钮在?
-
在每一行之前,打印目标。例如,在
self.downarrow?.alpha = 1.0之前,放置print(self.downarrow)。对每一行都这样做。运行应用程序并制作动画。打印什么?
标签: ios swift uiviewcontroller containers uianimation