Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 使用'时显示错误;动画的持续时间';_Swift_Block_Uiviewanimation - Fatal编程技术网

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

我是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中的块

隐藏在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
}

注意斯威夫特=摆动在回答问题之前,请阅读有用的标签弹出窗口。隐藏的可能副本无论如何都不可设置动画,因此不需要动画代码。