I am moving layers around using UIView.animate(withDuration:,animations:,completion:). The animation works as it is supposed to, but changing the duration parameter doesn't change the duration. It always goes at the same speed. What might I be doing wrong? Is there some global thing I have to turn on for this to work?
Animation duration won't change
What do you mean by moving layers around? Can you give an example?
My iOS app builds an interactive picture as a tree of CALayers. The user can touch and drag these layers around on the screen. In some circumstances, these motions "do something". In other circumstances, they don't "do something", and the layer that was dragged moves back to where it came from in a smooth animation. The animation works: I can see the smooth motion. What doesn't work is to make it move at different speeds by changing the duration parameter. Regardless of what number I put there, it always animates at the same speed. If you want to see it, look for "DragginMath" on the AppStore, or on YouTube. Those videos don't show the "moving back" behavior, but you'll get the idea.
Please show the code, it will tell much more on what the problem is.
Let's try this again.
The stuff with DispatchQueue was added as a result of a suggestion elsewhere. The behavior is the same, with or without the DispatchQueue wrapper.
internal func animateBack(_ aoTouchSession:TouchSession,reconnect ayReconnect:Bool = true) {
let ksCGPoint = aoTouchSession.hsCGPointLayer
projectStrokeColor(LOperand.gkoCGColorStroke)
DispatchQueue.main.async(execute:DispatchWorkItem(
qos:.unspecified,
flags:[],
block:{
UIView.animate(
withDuration:10,
animations:{self.frame.origin = ksCGPoint},
completion:{ay in if ay && ayReconnect {self.drawGlyphAndConnector()}}
)
}
))
}