func fixBeginTimeAnimation(anim: CAAnimation, beginTime: CFTimeInterval, endTime: CFTimeInterval){
if beginTime == 0 {return}

if let basicAnim = anim as? CABasicAnimation{
let duration = basicAnim.duration
let excessTime = endTime - duration
basicAnim.duration += excessTime + 0.01
basicAnim.speed = Float(1 + excessTime/duration)
}else if let keyAnim = anim as? CAKeyframeAnimation{
let duration = keyAnim.duration
let excessTime = endTime - duration
keyAnim.duration += excessTime + 0.01
keyAnim.speed = Float(1 + excessTime/duration)
}else if let groupAnim = anim as? CAAnimationGroup{
for subAnim in groupAnim.animations! as [CAAnimation]{
fixBeginTimeAnimation(subAnim, beginTime: beginTime, endTime: endTime)
}
}
}