Optimizing a drawing (with finger touches) application for iPhone SDK

前端 未结 5 1475
梦如初夏
梦如初夏 2021-02-04 19:35

I\'m writing an application that uses your finger to draw simple diagrams. I have it working for the most part but now I\'m trying to optimize its performance. When the user swi

5条回答
  •  Happy的楠姐
    2021-02-04 19:59

    drawRect gets called on the main thread. But you don't have to do this. You can use the main thread to collect UI events and do the drawing on a background thread. The background thread gets notified whenever there are new touches and starts a drawing operation in its own CGBitmapContext. Then you create a CGImage and hand it over to the View: view.layer.contents = drawingImage.

    If you need even more performance, consider drawing using OpenGL.

提交回复
热议问题