iPhone UIImageView pinch zoom

后端 未结 2 585
我寻月下人不归
我寻月下人不归 2021-02-10 17:36

I have been trying to implement pinch zoom/in-out for PhotoView (a UIImageView instance) using CGAffinTransformScale (planing to use rotation so can not count on frames for the

相关标签:
2条回答
  • 2021-02-10 17:51

    An answer from the left-field perhaps, but an alternative might be to place the UIImageView inside a UIScrollView, define a viewForZoomingInScrollView: method on your scroll view delegate, and set the maximumZoomScale/minimumZoomScale properties and you'll have your pinch zooming without needing to implement the calculations to set the transform yourself? I've just done this on a recent project and it worked well.

    0 讨论(0)
  • 2021-02-10 17:59

    Generally speaking, whenever you implement a continuous UI behavior, you need to measure it against something that does not change.

    So if your touches cause the View transformation to change, you should measure the touches against something that does not change - your parent view for instance. So, instead of calling :

    [touch locationInView:self]
    

    you should use

    [touch locationInView:[self superview]]
    

    I am not sure if this will fix your problem, but it will eliminate one possible cause of your troubles.

    0 讨论(0)
提交回复
热议问题