UIImageView vs UIView w/ Image - efficiency

前端 未结 2 822
盖世英雄少女心
盖世英雄少女心 2021-02-06 05:53

This is not really a question about addressing a specific problem but more a request to be pointed in the right direction.

I am making an app where I am loading several

2条回答
  •  执念已碎
    2021-02-06 06:36

    The design pattern is basically, use UIImageView. Apple has spent a lot of time making it fast, and Apple is allowed to use private APIs that you aren't.

    That said, if you want to do it yourself, you should try using one CALayer per image. You just load an image and set it as the content property of a CALayer. The CALayer can cache its contents in GPU memory, and may do other optimizations that you can't do with public APIs.

    You can learn a lot about making your UI fast by watching Apple's development videos. They include a lot of tips and "inside info" that are either not in the written documentation, or hard to find/easy to overlook in the docs. The development videos are here: http://developer.apple.com/videos/. Some good ones relevant to your question:

    • iOS - "Understanding iOS View Compositing"
    • WWDC 2011 - "Understanding UIKit Rendering"
    • WWDC 2011 - "Practical Drawing for iOS Developers"
    • WWDC 2011 - "Core Animation Essentials"
    • WWDC 2010 - "Core Animation in Practice"

提交回复
热议问题