且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UIImageView上的UIButtons缩放

更新时间:2022-11-16 07:54:52

制作一个视图以包含所有可缩放内容(所有内容都会出现),并称其为contentView.现在,将所需的所有内容放入该contentView,imageView和所有按钮等中.

Make a single view to contain all your zoomable content (everything it would appear), and call it say contentView. Now place everything you want in that contentView, the imageView and all your buttons etc.

在您的UIScrollView委托中放置以下内容:(如果尚未设置,请确保设置scrollView的委托)

In your UIScrollView delegate place this: (Be sure to set the scrollView's delegate if you haven't already)

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self.contentView;
}

仅允许一个视图缩放,但是该视图可以包含其他可缩放的视图,因为它们是子视图.

Only one view is allowed to zoom, but that one view can however contain other views that will scale because they're child views.

还要确保将scrollView的contentSize值设置为可缩放contentView的确切大小.

Also be sure to set the scrollView's contentSize value to the exact size of your zoomable contentView.