您想要的是Apple 编写的这个PhotoScroller 演示。我自己用过,效果很好。
特别检查 ImageScrollView 模块。它处理缩放。
这是 UIScrollView 标题中关于缩放的代码:
/*
the following properties and methods are for zooming. as the user tracks with two fingers, we adjust the offset and the scale of the content. When the gesture ends, you should update the content
as necessary. Note that the gesture can end and a finger could still be down. While the gesture is in progress, we do not send any tracking calls to the subview.
the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale: in order for zooming to work and the max/min zoom scale must be different
note that we are not scaling the actual scroll view but the 'content view' returned by the delegate. the delegate must return a subview, not the scroll view itself, from viewForZoomingInScrollview:
*/
@property(nonatomic) float minimumZoomScale; // default is 1.0
@property(nonatomic) float maximumZoomScale; // default is 1.0. must be > minimum zoom scale to enable zooming