Animate scrolling of UIScrollView with CoreAnimation

后端 未结 4 494
醉酒成梦
醉酒成梦 2021-02-07 09:24

Sorry for a big question, real question are bold in bottom, now some explanation.

I\'m use CoreAnimation in my project for animate some objects moving l

4条回答
  •  失恋的感觉
    2021-02-07 10:27

    You should read about animatable properties, Programming iOS 5

    Indeed, when you try to animate layers, Apple gives a set of animatable properties, but you're not limited to this set. You can animate whatever you want.

    In all cases, you shouldn't use kCAFillModeForwards because it will ask the device to redraw forever the last presentation layer that was used for the animation, instead of using a cached representation of the layer.

    So the way you could achieve such a thing would be by defining a specific layer of yours where the contentOffset property is defined as animatable. And in order to work, you should start by verifying what kind of top layer class is used by a scrollview, so that, by subclassing it and setting the wanted property (contentOffset) animatable, and subclassing your scrollview by setting this layer as the top layer of the scrollview, you could possibly achieve what you're trying to do.

    This is theory!

    But this is what I would try. Look for this method and its behavior and intents

    + (BOOL)needsDisplayForKey:(NSString *)key
    

    Another thing you could read is this A start example. But this also means you should redraw your uiscrollview by yourself!

提交回复
热议问题