gpt4 book ai didi

ios - 在 Swift 3 中设置 CABasicAnimation 委托(delegate)问题?

转载 作者:IT王子 更新时间:2023-10-29 05:27:10 25 4
gpt4 key购买 nike

我收到以下错误

Cannot assign value of type 'StarButton' to type 'CAAnimationDelegate?'

在此 CABasicAnimation block 的最后一行:

 let fillCircle = CABasicAnimation(keyPath: "opacity")
fillCircle.toValue = 0
fillCircle.duration = 0.3
fillCircle.setValue(notFavoriteKey, forKey: starKey)
fillCircle.delegate = self // this is where the error is thrown

self 是一个自定义的 UIButton 类。这在以前的 Swift 版本中不是问题……对解决方案有什么建议吗?

更新

以下是 StarButton 类源文件的可下载链接,以供最佳引用:

https://www.dropbox.com/s/gvc2sky05f4p3au/StarButton.swift?dl=0

最佳答案

正如@Doc在上面的评论中提到的,解决方案是更换

class StarButton: UIButton { 

class StarButton: UIButton, CAAnimationDelegate {

似乎不再隐含 CAAnimationDelegate 协议(protocol),必须明确指定。

关于ios - 在 Swift 3 中设置 CABasicAnimation 委托(delegate)问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38648000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com