static func animate(_ duration: TimeInterval,animations: (() -> Void)!,delay: TimeInterval = 0,options: UIViewAnimationoptions = [],withComplection completion: (() -> Void)! = {}) { UIView.animate( withDuration: duration,delay: delay,options: options,animations: { animations() },completion: { finished in completion() }) }
Using above class in my swift file and create function like below
SPAnimation.animate(durationScalingRootView,animations: { rootViewController.view.transform = CGAffineTransform.identity },delay: delayScalingRootView,options: UIViewAnimationoptions.curveEaSEOut,withComplection: { finished in //rootViewController.view.layer.mask = nil })
得到此错误
Contextual closure type ‘() -> Void’ expects 0 arguments,but 1 was
used in closure body
解决方法
问题出在这里:
withComplection: { finished in //rootViewController.view.layer.mask = nil }
如果查看方法声明,则完成处理程序的类型为(() – > Void)!.它不需要任何论据.上面的闭包需要一个参数 – 完成.结果,发生错误.
从闭包中删除完成的参数:
withComplection: { //rootViewController.view.layer.mask = nil }
static func animate(_ duration: TimeInterval,withComplection completion: ((Bool) -> Void)? = nil) { UIView.animate( withDuration: duration,animations: { animations() },completion: { finished in completion?(finished) }) }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。