UIKit Dynamics with existing affine transform

后端 未结 4 681
我在风中等你
我在风中等你 2021-02-14 19:07

I have a view that has some scale transformations. And when I apply some UIKit Dynamics on it, it zeroes them out. /: How can I keep the existing transformation on the view whil

4条回答
  •  無奈伤痛
    2021-02-14 19:40

    Inspired by this answer, I have a solution: update the transform on every frame of the animation

    let attachment = UIAttachmentBehavior(item: item, attachedTo: item) // Workaround - attach the item to itself
    attachment?.action = { () in
        item.transform = item.transform.scaledBy(x: 1.5, y: 1.5)
    }
    
    animator.addBehavior(attachment)
    

提交回复
热议问题