How to rotate image around center point automatically with finger touch

前端 未结 3 594
小蘑菇
小蘑菇 2021-01-17 04:38

On iPhone, how to implement rotating image around the center point using finger touch ?

Just like wheel, if you put finger on the iPhone screen , then move suddenly,

3条回答
  •  深忆病人
    2021-01-17 04:56

    I would use the affine transformations - yuou can assign a transformation to any layer or UI element using the transform property.

    You can create a rotation transform using CGAffineTransform CGAffineTransformMakeRotation( CGFloat angle) which will return a transformation that rotates an element. The default rotation should be around the centerpoint.

    Be aware, the rotation is limited to 360 degrees, so if you want to rotate something more than that (say through 720 degrees) - you have to break the rotation into several sequences.

    You may find this SO article useful as well.

提交回复
热议问题