Ios 为什么';当我将UIView动画放在不同类的containerView中时,它不工作吗?
我在Ios 为什么';当我将UIView动画放在不同类的containerView中时,它不工作吗?,ios,swift,uiviewcontroller,containers,uianimation,Ios,Swift,Uiviewcontroller,Containers,Uianimation,我在UIView上做了一个简单的动画,它按照我想要的方式工作。但是当我分离代码时,它就停止工作了。我已将应设置动画的UIView放入containerView中,并且containerView连接到animationCode类。“main”viewController具有独立的类,以及触发动画的按钮 从主视图控制器: bottomTableView.rx.modelSelected(ModeButtons.self) .subscribe(onNext: { [weak self] va
UIView
上做了一个简单的动画,它按照我想要的方式工作。但是当我分离代码时,它就停止工作了。我已将应设置动画的UIView
放入containerView
中,并且containerView
连接到animationCode
类。“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)
以及其中一个动画功能:
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)
})
}
下面的图片可以更好地解释设置:左边是带有ui视图的containerView
,下面是按钮。就像我之前说的。当所有内容都在同一个viewController
和类中时,这种方法工作得很好。那么,为什么动画现在不能工作呢?我错过了什么?
有时将动画代码放入主队列可以解决此问题
DispatchQueue.main.async {
UIView.animate(withDuration: 0.3) {
}
}
animationOne
调用此函数?是的,它贯穿整个过程,但没有动画显示…请发布更多代码。。。。或检查出口。。您的图像位于容器中或按钮位于?在每行之前,打印目标。例如,在self.downarrow?.alpha=1.0
之前,放置print(self.downarrow)
。每行都这样做。运行应用程序并制作动画。什么指纹?