简体   繁体   中英

How optimized is UIView UIImageView?

In a game I'm building I want to make a UIView that represents a tiled map. I'd like to know if a UIView filled with a grid of UIImageViews would lag when animated around the screen? My first thought is that if UIVIew was really optimized the subviews would know not to draw themselves if they weren't on screen, but I don't know the details of how UIView optimizes drawing.

Also, if this approach is possible, is there an upper bound on how many 64x64 pixel tiles I could have in one view before it has issues?

If you want to represent a tiled map, why not use CATiledLayer ? This is what provides support for the tiling seen in, for example, Maps. It provides asynchronous drawing of tiles with crossfading, support for different zoom levels, etc.

If you were to go with your original idea, I would suggest that you remove imageviews that are offscreen (assuming a large-enough grid to begin with). It's easy enough to do that with the scrollview delegate methods. Given that, any lag you experience would probably be due to trying to process a bunch of image data on the main thread (which is one benefit of CATiledLayer ; all the drawing happens on background threads).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM