I have a function that makes an image in my view "shake" back and forth. I can set how long I want it to shake and the speed, but what I really need is for it to shake every 10 seconds.
Here is the function I'm working with, it's simply called once in viewDidLoad to get it to work once.
func shakeView(){
let shake:CABasicAnimation = CABasicAnimation(keyPath: "position")
shake.duration = 0.4
shake.repeatCount = 5
shake.autoreverses = true
shake.speed = 9.0
let from_point:CGPoint = CGPointMake(homeLogo.center.x - 5, homeLogo.center.y)
let from_value:NSValue = NSValue(CGPoint: from_point)
let to_point:CGPoint = CGPointMake(homeLogo.center.x + 5, homeLogo.center.y)
let to_value:NSValue = NSValue(CGPoint: to_point)
shake.fromValue = from_value
shake.toValue = to_value
homeLogo.layer.addAnimation(shake, forKey: "position")
}
I haven't had any lucking finding out how I might be able to do this. Any help or pointing in the right direction would be greatly appreciated.