1
我有这个功能动画一个UIImageView:无“+”候选人产生预期的语境结果类型‘AnyObject’斯威夫特错误3
override func deselectAnimation(_ icon : UIImageView, textLabel : UILabel, defaultTextColor : UIColor) {
playMoveIconAnimation(icon, values:[icon.center.y + 4.0, icon.center.y])
playDeselectLabelAnimation(textLabel)
textLabel.textColor = defaultTextColor
if let iconImage = icon.image {
let renderImage = iconImage.withRenderingMode(.alwaysTemplate)
icon.image = renderImage
icon.tintColor = defaultTextColor
}
}
func playMoveIconAnimation(_ icon : UIImageView, values: [AnyObject]) {
let yPositionAnimation = createAnimation("position.y", values:values, duration:duration/2)
icon.layer.add(yPositionAnimation, forKey: "yPositionAnimation")
}
后,我升级到斯威夫特3我开始收到以下错误:
No '+" candidates produce the expected contextual result type 'AnyObject'
我在一个类似question该函数应该有返回值的阅读,但我不知道如何实现这一点。我会感激你的帮助解决这个错误
发布函数* playMoveIconAnimation *的签名。 – xhamr
您好@xhamr, FUNC playMoveIconAnimation(_图标:的UIImageView,值:[AnyObject]){ 让yPositionAnimation = createAnimation( “position.y”,值:值,持续时间:持续时间/ 2) icon.layer。添加(yPositionAnimation,forKey:“yPositionAnimation”) } –
尝试像这样'CGFloat(icon.center.y + 4.0)' –