So what do I mean by "truly" custom animations. I mean an animation that you don't use any frameworks for, that you effect by manipulating the values of the view yourself by such small amounts and with such frequency that the change is fluid.
For example, I have a drag and drop gesture recognizer for stackviews; although I've made some alterations not reflected in that file. The problem with it is that it does not account for scrollable lists in that you want the list to scroll upwards if you want to move an item your dragging to a position not visible within the bounds of the scrollview. So when you drag it close to the top, you want it to scroll upwards; and same for the bottom.
I tried using UIView.animate(...)
to change the offset to zero at an acceptable rate — and then cancel it if it moves sufficiently far from the top or reaches beginning — but on doing so the arranged subview that was being dragged immediately disappears. I'll be honest I don't remember whether it ends up getting placed wherever you happened to be holding it over at that time, or it goes back to where it started; but it doesn't work.
So I decided to do this manually. Change the content offset at a rate that effects fluid scrolling. So the increment/decrement is tentatively 0.34
. And I change it at a rate starting from once every 5 milliseconds down to as fast as possible — depending on how close the touch is to the top of the scrollview frame. The change is affected using a loop in a background thread that sleeps in each iteration, and how long it sleeps for depends on how close the user is to the top/bottom. The closer, the faster, so the less it sleeps for.
I'm wondering if executing changes to the UI thread with such frequency is an established bad idea, if that's exactly how Apple does it... Basically whether it's safe or not — will there be a high probability of crashes resulting from engaging that functionality? It absolutely does not crash during testing because of this, but it wouldn't be the first time that things worked for me during testing but failed after being shipped.