大 UIImage 滚动性能
我有一个大的 UIimage (2000x2000)。每次应用启动时绘制的图像,并复制到 CALayer。 当前时间我将 UIScrollView 放在主视图上,并使用绘制的图像制作 CALayer。 在小变焦上滚动看起来不错。但在最小缩放时,当整个图像可见时,图像滚动速度减慢,它对移动触摸不敏感。
那么,问题来了。我可以做什么来提高滚动性能?
I have a big UIimage (2000x2000). Image drawed every time on app start, and copied to CALayer.
On Current time i put UIScrollView on main view, and make CALayer with drawn image.
Scrolling on small zoom looks fine. But on min zooming , when whole image visible, image scroll slowed, it becomes not quick responsible on move touch.
So, the question. What can I do, to increase scrolling performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我采取的方法是在较低的缩放级别(较低=缩小)下使用图像的较低分辨率版本。
首先,请参阅这篇文章以调整 UIImage 的大小。
响应 UIScrollViewDelegate 中的scrollViewDidEndZooming:withView:atScale: 方法,并在达到一定缩放级别时切换图像。这需要一些尝试和错误才能找到正确的平衡。您甚至可能想以几种不同的分辨率渲染图像。请务必提前生成不同大小的 UIImage,以便缩放时不会出现延迟。
The approach I would take is to use a lower resolution version of your image at lower zoom levels (lower = zoomed out).
First, see this post for resizing UIImages.
Respond to the scrollViewDidEndZooming:withView:atScale: method in UIScrollViewDelegate, and switch the images when a certain zoom level is reached. This will take some trial and error to find the correct balance. You may even want to render your image at several different resolutions. Be sure to generate the different sized UIImages in advance so there is no delay while zooming.