我尝试制作淡出动画和如下代码。 但是我遇到了类似标题的错误,我不知道如何解决。 任何可以帮助我的人吗?谢谢!!
private func showAnimation(){
if self.resultPresent.alpha == 1.0{
UIView.animate(withDuration: 2,option: .curveEaseOut, animations: {
self.resultPresent.alpha = CGFloat(0)→Expression type '@lvalue CGFloat' is ambiguous without more context
})
}
}
答案 0 :(得分:1)
没有UIView.animate
版本的参数。
尝试以下方法:
UIView.animate(withDuration: 2, delay: 0, options: .curveEaseInOut, animations: {
self.resultPresent.alpha = 0
})
,或者是默认情况下使用.curveEaseInOut
的以下较短形式:
UIView.animate(withDuration: 2, animations: {
self.resultPresent.alpha = 0
})
答案 1 :(得分:1)
请使用以下代码。您正在使用的功能的参数似乎已更改
private func showAnimation()
{
if self.resultPresent.alpha == 1.0
{
UIView.animate(withDuration: 2.0, delay: 0.0, options: .curveEaseOut, animations: {
self.resultPresent.alpha = 1.0 // Final value of alpha
}, completion: nil)
}
}