【发布时间】:2014-09-24 16:32:21
【问题描述】:
UIView 需要根据自定义控件的完成处理程序更改警告标签:
voucherInputView.completionHandler = {[weak self] (success: Bool) -> Void in
self?.proceedButton.enabled = success
self?.warningLabel.alpha = 1.0
if success
{
self?.warningLabel.text = "Code you entered is correct"
self?.warningLabel.backgroundColor = UIColor.greenColor()
}
else
{
self?.warningLabel.text = "Code you entered is incorrect"
self?.warningLabel.backgroundColor = UIColor.orangeColor()
}
UIView.animateWithDuration(NSTimeInterval(1.0), animations:{ ()-> Void in
self?.warningLabel.alpha = 1.0
})
最终的动画块在表单中显示错误。
Cannot invoke 'animateWithDuration' with an argument list of type '(NSTimeInterval), animations: ()-> Void)'
如果我在完成闭包之外的某个地方调用它,它会起作用。
【问题讨论】:
标签: uiview swift closures uianimation completionhandler