Present and zoom large images on iOS without CATiledLayer

别说谁变了你拦得住时间么 提交于 2019-12-06 15:45:31

问题


I'd like to present and allow the user to zoom large images on the iPhone and iPad in much the same way that the Photos app works.

I realize CATiledLayer is the goto class for this, but the aesthetic it uses won't work for my application. It renders tiles one after another, while the Photos app renders the whole screen at once (and shows a pixellated version during and after a zoom until the app can catch up).

I could certainly implement a view which renders the image in the background after each zoom. However, once the source image gets to large, this will crash the app. So tiling is appealing, I would just prefer to not update the screen until all tiles are ready (and show a lower-res image in the meantime).

Has anyone tried to implement something like this? Any ideas?


回答1:


I guess you can have two views: one ImageView with a low res image, and on top a custom view with a CaTiledLayer, with transparent background and hidden at the beginning.

So, when zooming (you'll need to apply zoom to both views) and you need extra resolution, just show the catiledlayered view, so it will load tiles while showing the lowres (and pixelated) on not loaded tiles.




回答2:


Apple's PhotoScroller and ScrollViewSuite samples show how to do this and more.

  • http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html
  • http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/Introduction/Intro.html

There's also a 2010 WWDC video titled "Designing Apps with Scroll Views" that explains PhotoScroller.

  • https://developer.apple.com/videos/wwdc/2010/


来源:https://stackoverflow.com/questions/8996268/present-and-zoom-large-images-on-ios-without-catiledlayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!