I am trying to create a size switching animation for this simple custom TUIScrollView class (from an open source TwUI project and very similar to the UIScrollView) that I created. It's called TUILayout and supports horizontal layout, as well as vertical, animated inserts and deletes, and has a more declarative way of providing data for cells, which I prefer for delegation. It recycles views similar to TUITableView or UITableView. In any case, if you want to follow, this is just one class and is located here.
https://github.com/mrjjwright/TUILayout .
In the code example, the user clicks the blue button in the lower left corner and all the lines are smoothly compressed to a size where the user can reorder and delete several lines (right-click on the line in the example to see this in action), etc. and then the user switches the lines back to their original size by pressing the blue button again.
By doing this resizing in setObjectHeight:animated , I first resize the model objects that represent the strings, recalculate and set the contentSize in TUIScrollView, cyclically in all new views (say 10 views will correspond to a reduced view, so dequeueReusableView and addSubview are called 10 times) And finally, I am animating the frames of all the views, their size and location in layoutSubviews.
The result is that scrollview is correctly compressed to a size in which the scroll bar is no longer displayed, images that are smoothly updated on the screen, to their reduced size, but recently added objects that can now fit into the visibleRect animation later as one block of subtitles .
Thus, all the recently added subviews lag behind the views that were on the screen, and I cannot understand why the animation doesnβt all happen together. I have tried many different combinations of things with no luck, including CATransactions. I am wondering if this works with CAScrollLayer or if someone can help me think this through.
A more general problem is how to smoothly handle resizing animations on scrollviews that recycle their views, and I looked at several other grids in the iOS world and got some inspiration, but I'm looking more.
Thank!
cocoa core-animation
John Wright Dec 04 2018-11-11T00: 00Z
source share