Empty UIView with minimal drawRect: overhead

Posted by Benjohn Barnes on Stack Overflow See other posts from Stack Overflow or by Benjohn Barnes
Published on 2009-05-27T09:33:34Z Indexed on 2010/05/30 9:02 UTC
Read the original article Hit count: 403

Filed under:
|
|
|

Hi,

I have an application that has three nested views that are mechanically important, but have no visual elements:

  • A vanila UIView that doesn't have any content of its own, and is simply used as a host for CALayers.
  • A UIScrollView (that is queried for it's origin and used to position CALayers in 3d: I really only use this view to faithfully replicate the scroll view's "mechanics"),
  • The scroll view's contents: a UIView subclass. It simply picks up touch events and passes them to a delegate - all that is important are its UIResponder machinery.

The UIView hosting CALayers is a sibling of a UIImageView that is a background image over which the CALayers are drawn.

I'd really like to ensure that none of these empty UIViews have any drawing or compositing overhead (in time, or storage) associated with them, or if that's not possible, to get this overhead as small as possible, and to understand it so that I can perhaps decide if I should try a different approach.

In interface builder, I've set all of the views to not clear their context before drawing. I've not set them to be opaque though, because they definitely are not opaque - they are completely transparent. I've found that I need to give the scroll view contents a transparent clear colour (again in IB by setting the background colour's opacity to zero), and this suggests that it is being drawn, which I don't want.

So, in short, I've not got much idea of what is and isn't getting drawn (anyone know of a tool like Quartz Debug for iPhone / simulator?), or how to go about stopping things from getting drawn.

Advice would be very welcome! Thanks, Benjohn

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiview