Swift 使用'时显示错误;动画的持续时间';
我是Swift新手,无法解决问题,请指导我 像这样使用它Swift 使用'时显示错误;动画的持续时间';,swift,block,uiviewanimation,Swift,Block,Uiviewanimation,我是Swift新手,无法解决问题,请指导我 像这样使用它 UIView.animateWithDuration(duration, delay: 0.0, options: option, animations: { () -> Void in self.btnCallButton.hidden = true }, completion: nil) 它显示以下错误 Cannot invoke 'animateWithDuration' with an ar
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中的块隐藏在swift中不可设置动画。如果要通过淡入/淡出隐藏/显示,请使用以下淡出代码
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
})
和法登的追随者
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
}
注意斯威夫特=摆动在回答问题之前,请阅读有用的标签弹出窗口。隐藏的可能副本无论如何都不可设置动画,因此不需要动画代码。