开发者

Performance issues : UIView coregraphics drawing inside a Customcell

开发者 https://www.devze.com 2023-03-13 13:08 出处:网络
I am implementing a UItableView with custom cells. My custom cell has a UIView inside of it. I am trying to draw extensive CoreGraphics shapes with gradients in the UIView and I am running into scro

I am implementing a UItableView with custom cells. My custom cell has a UIView inside of it.

I am trying to draw extensive CoreGraphics shapes with gradients in the UIView and I am running into scrolling performance problems -- since the customcell's UIView is getting drawn upon everytime the cell gets displayed.

Are there ways where I could do this differently (such as say, some kind of lazy drawing, drawing asynchronously, UIView caching, preventing the cell from redrawing etc) so as to improve performance?

Deeply appreciate any help, inputs, insight开发者_JAVA技巧s.


The idea is not to compute your graphics every time at draw time, but to render it offscreen in a UIImageView. Then your cell only has to blit the image, which is as fast as can be.

You can still compute your images lazily and asynchronously. The structure of your code could be similar to the Apple sample code LazyTableImages. Google for it. In that sample code, what's slow is not the drawing time, but the network loading time, but that difference is not significant.

0

精彩评论

暂无评论...
验证码 换一张
取 消