【发布时间】:2017-11-01 06:38:48
【问题描述】:
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()
})
}
在我的 swift 文件中使用上面的类并创建如下函数
SPAnimation.animate(durationScalingRootView,
animations: {
rootViewController.view.transform = CGAffineTransform.identity
},
delay: delayScalingRootView,
options: UIViewAnimationOptions.curveEaseOut,
withComplection: {
finished in
//rootViewController.view.layer.mask = nil
})
得到这个错误
上下文闭包类型 '() -> Void' 需要 0 个参数,但 1 是 用于闭包体
【问题讨论】:
-
你应该把参数和左大括号放在同一行。
标签: swift