本文介绍了在快速静态错误中对自定义UIView进行动画处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为自定义UIView设置动画,但它给了我错误:
静态成员'animate'不能用于类型为'Tyle'的实例
I'm trying to animate a custom UIView but it gives me the error:Static member 'animate' cannot be used on instance of type 'Tyle'
这是我的课程:
class Tile: UIView {
var actualPosition:Position = Position(dimX: 0,dimY: 0)
var correctPosition:Position = Position(dimX: 0,dimY: 0)
var imageView: UIImageView = UIImageView()
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(imageView)
imageView.translatesAutoresizingMaskIntoConstraints = false
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
这是我正在使用的代码:
And this the code I'm using:
for i in 0...self.tilesMovedIndex.count - 1 {
let view = self.gameTiles[self.tilesMovedIndex[i]]
view.animate(withDuration: 0.5, delay: 0.3, options: [.repeat, .curveEaseOut, .autoreverse], animations: {
}, completion: nil)
}
我想我在创建类时会丢失某些东西,或者我应该使用另一个函数,但我看不到问题。
I suppose I'm missing something when creating the class or maybe I should use another function but I can't see the problem.
谢谢
推荐答案
动画
是静态方法。因此应该是
animate
is a static method. So it should be
UIView.animate(withDuration: 0.5, delay: 0.3, options: [.repeat, .curveEaseOut, .autoreverse], animations: {
}, completion: nil)
这篇关于在快速静态错误中对自定义UIView进行动画处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!