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'
This is my class:
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.
Thanks for the help!