I know that external change to center
, bounds
and transform
will be ignored after UIDynamicItem
s init.
But I need to manually change the transform
of UIView
that in UIDynamicAnimator
system.
Every time I change the transform
, it will be covered at once.
So any idea? Thanks.
Any time you change one of the animated properties, you need to call
[dynamicAnimator updateItemUsingCurrentState:item]
to let the dynamic animator know you did it. It'll update it's internal representation to match the current state.EDIT: I see from your code below that you're trying to modify the scale.
UIDynamicAnimator
only supports rotation and position, not scale (or any other type of affine transform). It unfortunately takes overtransform
in order to implement just rotation. I consider this a bug inUIDynamicAnimator
(but then I find much of the implementation of UIKit Dynamics to classify as "bugs").What you can do is modify your bounds (before calling
updateItem...
) and redraw yourself. If you need the performance of an affine transform, you have a few options:CALayer
or subview and modify its scale (updating yourbounds
to match if you need collision behaviors to still work).<UIDyanamicItem>
on anNSObject
) that passes the transform changes to you. You can then combine the requested transform with your own transform.