使用 'animateWithDuration' 时显示错误
Showing error while using 'animateWithDuration'
我是Swift的新人,所以无法弄清楚问题,请指导我
喜欢使用它
UIView.animateWithDuration(duration, delay: 0.0, options: option, animations: { () -> Void in
self.btnCallButton.hidden = true
}, completion: nil)
它显示以下错误
Cannot invoke 'animateWithDuration' with an argument list of type '(Float, delay: FloatLiteralConvertible, options: UIViewAnimationOptions, animations: () -> Void, completion: NilLiteralConvertible)'
请提供所需的建议并提供一些描述 swift
中的块的链接
Hidden 在 Swift 中不可设置动画。如果你想通过 fade in/out hide/show 使用以下代码进行 fadeout
UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: {
self.btnCallButton.isHidden = false
self.btnCallButton.alpha = 0.0
}, completion: { finished in
self.btnCallButton.isHidden = true
})
以及 fadein 的后续
UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: {
self.btnCallButton.isHidden = false
self.btnCallButton.alpha = 1.0
}, completion: { finished in
})
在闭包末尾添加 return
作为
UIView.animate(withDuration: duration, delay: 0.0, options: option, animations: { () -> Void in
self.btnCallButton.hidden = true
return
}, completion: nil)
像这样:
UIView.animate(withDuration: 0.35) {
// animate things
return
}
我是Swift的新人,所以无法弄清楚问题,请指导我
喜欢使用它
UIView.animateWithDuration(duration, delay: 0.0, options: option, animations: { () -> Void in
self.btnCallButton.hidden = true
}, completion: nil)
它显示以下错误
Cannot invoke 'animateWithDuration' with an argument list of type '(Float, delay: FloatLiteralConvertible, options: UIViewAnimationOptions, animations: () -> Void, completion: NilLiteralConvertible)'
请提供所需的建议并提供一些描述 swift
中的块的链接Hidden 在 Swift 中不可设置动画。如果你想通过 fade in/out hide/show 使用以下代码进行 fadeout
UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: {
self.btnCallButton.isHidden = false
self.btnCallButton.alpha = 0.0
}, completion: { finished in
self.btnCallButton.isHidden = true
})
以及 fadein 的后续
UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: {
self.btnCallButton.isHidden = false
self.btnCallButton.alpha = 1.0
}, completion: { finished in
})
在闭包末尾添加 return
作为
UIView.animate(withDuration: duration, delay: 0.0, options: option, animations: { () -> Void in
self.btnCallButton.hidden = true
return
}, completion: nil)
像这样:
UIView.animate(withDuration: 0.35) {
// animate things
return
}