我想用 UIImage 设置 UIImageView 并将这个 imageview 放在 UIScrollView 中以获得这个图像的缩放;我希望这个 UIImageView 和 UIScrollView 适合视图中心的矩形...有可能吗?
<UIScrollViewDelegate>UIScrollView 绘制为视图中心矩形所需的大小.将检查器中的最大缩放设置为大于 1 的值.例如 4 或 10.UIScrollView 中绘制您的 UIImageView 并使用您想要的任何图像进行设置.使其与 UIScrollView 的大小相同.UIImageView 拖动到 View 控制器的 .h 中,为 UIImageView 创建一个 IBOutletcode>,把它称为 imageView 之类的聪明东西.添加此代码:
<块引用>-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView{返回self.imageView;}运行应用程序并捏合和平移,直到心满意足.
I want to set a UIImageView with a UIImage and put this imageview inside a UIScrollView to obtain a zoom of this image;
and I want this UIImageView and UIScrollView to fit in the rect at the center of the view...is it possible?
<UIScrollViewDelegate>UIScrollView the size you want for the rectangle at the center of the view. Set the max zoom in the inspector to something bigger than 1. Like 4 or 10.UIImageView in the UIScrollView and set it up with whatever image you want. Make it the same size as the UIScrollView.UIImageView to the .h of your View controller to create an IBOutlet for the UIImageView, call it something clever like imageView.Add this code:
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; }
Run the app and pinch and pan til your heart's content.
这篇关于IOS:在滚动视图中添加图像视图以进行缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何继承 UIScrollView 并使委托属性私有How to subclass UIScrollView and make the delegate property private(如何继承 UIScrollView 并使委托属性私有)
Swift - 如何从照片库中获取最后拍摄的 3 张照片Swift - how to get last taken 3 photos from photo library?(Swift - 如何从照片库中获取最后拍摄的 3 张照片?)
以编程方式设置 contentOffset 触发 scrollViewDidScrolSetting contentOffset programmatically triggers scrollViewDidScroll(以编程方式设置 contentOffset 触发 scrollViewDidScroll)
使用 pagingEnabled 的 UIScrollView 中页面之间的照片应Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中页面之间的照片应用程序式间隙
为什么 UIScrollView 在 ios 6 和 ios 7 中从顶部留下空why UIScrollView is leaving space from top in ios 6 and ios 7(为什么 UIScrollView 在 ios 6 和 ios 7 中从顶部留下空间)
UIScrollView 在滚动时暂停 NSTimerUIScrollView pauses NSTimer while scrolling(UIScrollView 在滚动时暂停 NSTimer)