backgroundColor
在嵌套方法中更改其颜色属性后,是否有任何理由UIView
会跳回其原始颜色UIView.animate
?我在动画期间将其设置为清除,然后在我最后一秒到最后一个完成时它跳回白色。
我已经尝试转换为animateWithKeyframes
,但我仍然有类似的情况。
基本上我正在尝试将视图用作蒙版并在标签上对其进行动画处理。我有一个darkModeBool
指示用户是否想要深色主题。darkModeBool
如果设置为 true ,我希望 label.textColor 和 view.Background 颜色在碰到该动画块时根据我设置的主题协议进行相应更改。
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()
})
})
}
}
当视图应该backgroundColor
在倒数第二个完成时改变它,firstMaskView
然后secondMaskView
回到白色覆盖文本。非常感谢任何输入。