What is the best way to show large UIView on UIScrollView?

后端 未结 2 1189
夕颜
夕颜 2021-01-19 05:48

I have an large UIView. Its variable size. It may be larger than 5000x5000 size. I draw lines, circles on it using UIBezierPath. Also

相关标签:
2条回答
  • 2021-01-19 06:21

    I think that you can use tiling with CATiledLayer, to lower the memory pressure, but it all depends about what you are loading, when, and some other aspects. Tiling is a complex topic, you can find more info here

    0 讨论(0)
  • 2021-01-19 06:26

    Subclass UIView and implement the +layerClass method in it:

    +layerClass
    {
        return [CATiledLayer class];
    }
    

    This causes your view to be backed by CATiledLayer instead of a single, huge CALayer (which would consume too much memory at that size).

    Then you just implement -(void)drawRect:(CGRect)rect in your custom view class and do all of your drawing in there. I had to do this recently in my project which uses UIScrollViews to scroll over an area that can be as big as 10000 x 150000.

    0 讨论(0)
提交回复
热议问题