UIView的背景颜色在完成后会不断恢复为原始颜色

时间:2019-01-23 07:59:00

标签: swift uiview uikit uiviewanimation uibackgroundcolor

在嵌套的backgroundColor方法中更改UIView的{​​{1}}的color属性后,是否有任何原因会跳回其原始颜色?我将其设置为在动画过程中清除,然后在我倒数第二次完成时跳回白色。

我尝试过转换为UIView.animate,但仍然有类似的情况。

基本上,我试图将视图用作蒙版,并在整个标签上对其进行动画处理。我有一个animateWithKeyframes,它指示用户是否想要深色主题。如果darkModeBool设置为true,我希望label.textColor和view.Background颜色在遇到动画块时会根据我设置的主题协议进行相应更改。

darkModeBool

当视图要更改时,倒数第二次完成时是func animateGraphic() { firstMaskWidthConstraint.constant = 0 UIView.animate(withDuration: 1.2, delay: 1, options: .curveLinear, animations: { self.view.layoutIfNeeded() self.firstMaskView.backgroundColor = .clear print("1") }) { (_) in self.secondMaskHeightConstraint.constant = 0 UIView.animate(withDuration: 0.8, delay: 0, options: .curveEaseIn, animations: { self.view.layoutIfNeeded() self.secondMaskView.backgroundColor = .clear print("2") }, completion: { (_) in UIView.animate(withDuration: 1, delay: 0.8, options: .curveEaseInOut, animations: { self.view.layoutIfNeeded() self.view.backgroundColor = SproutTheme.current.backgroundColor.cgColor self.sproutLabel.textColor = SproutTheme.current.textColor }, completion: { (_) in RunLoop.current.run(until: Date(timeIntervalSinceNow: 1.8)) self.popToNavigationStack() }) }) } } backgroundColorfirstMaskView会变回白色以覆盖文本。任何输入,我们将不胜感激。

0 个答案:

没有答案
相关问题