How to rotate and resize the image view with single finger

后端 未结 3 1606
我寻月下人不归
我寻月下人不归 2020-12-15 02:17

I am developing an app which has feature that resizing and rotating the imageview by dragging its bottom right corner button.

I saw one app which has feature that if

相关标签:
3条回答
  • 2020-12-15 02:22

    I had hitted the same obstacle as yours, so I developed my own modules ZDStickerView. It would be nice reference.

    First of all, be sure your view's autoresizingMask should be flexible.

        autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
    

    otherwise resizing wouldn't work properly.

    Second, I recommends you to use "CGAffineTransformMakeRotation" and "atan2" functions to solve the rotation problem, like this:

        float ang = atan2([recognizer locationInView:self.superview].y - self.center.y,
                          [recognizer locationInView:self.superview].x - self.center.x);
        float angleDiff = deltaAngle - ang;
        self.transform = CGAffineTransformMakeRotation(-angleDiff);
    

    Third, be sure to use relative coordinate, like this:

        self.transform = CGAffineTransformMakeRotation(-angleDiff);
    
    0 讨论(0)
  • 2020-12-15 02:29

    I have fixed this issue and uploaded this control in cocoacontrols

    http://www.cocoacontrols.com/controls/tdresizerview

    And sample code

    https://www.dropbox.com/s/yb0vzy0wao52bgt/SampeResizeView.zip

    Updated answer

    https://www.cocoacontrols.com/controls/zdstickerview

    0 讨论(0)
  • 2020-12-15 02:32

    This might help, https://github.com/zedoul/ZDStickerView.

    IQStickerView with OneFingerRotation, Scale, Resize and Close feature.

    Features:

    1. One Finger Rotation Scale.
    2. One Finger Resize.
    3. Enable/Desable Rotation, Scale, Resize with properties.
    4. Auto manage Multiple IQStickerView.
    5. Can work with UIScrollView also.
    6. Fast Responsiveness.
    0 讨论(0)
提交回复
热议问题