Search code examples
cocoa-touchuitableviewuikitdrawrect

Using drawRect to draw tablecell


So, I watched some WWDC 2010 videos, and in one video the speaker pointed out that it could be a good option to draw the custom tablecells using drawRect instead of putting them in IB, because it would be good for performance. I have always put them in IB, so I'd like to ask how I actually do it, just by overriding the drawRect function of the tablecell? Also is it worth it to use drawRect instead of IB?

Thanks, if you have something to ask I will elaborate.


Solution

  • UITableViewCell is a subclass of UIView, so yes, if you want to create one that does custom drawing you should override -drawRect:. There might be some situations where this gives improved performance, but it's probably not significantly different in the usual case where you're recycling cells and all the cells are similar.