edit: Forgot to mention, if your going to use this your'l need to import QuartzCore.
Code:
#import <QuartzCore/QuartzCore.h>
It is a VERY efficient way. You should avoid drawRect code for views that you place in a table view. Adding borders to the image view's layer is exactly what you should do.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I was under the impression drawing the entire cell's contentView yourself in drawRect was the best way of doing things..?
Quite the opposite.
Apple says all over the place to avoid overriding drawRect whenever possible.
If you have an overridden drawRect method, the system has to call it every time the view needs updating. It then has to copy what you've drawn over to the graphics hardware, for each frame. That makes animations sluggish.
If you let the system draw the control for you, it can render the contents to a bitmap once, install it to a tile in the graphics hardware, and then render it as needed, including moving, rotating, scaling, and other transformations.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I've been using the drawRect method since Loren Britcher made that blog post about smooth scrolling in UITableViews and I've been getting 60FPS since then. It can't just be luck?
I've been using the drawRect method since Loren Britcher made that blog post about smooth scrolling in UITableViews and I've been getting 60FPS since then. It can't just be luck?
I just did a little digging, and I guess I overstated the issue. The issue is using drawRect and setNeedsDisplay to roll your own animation.
When you do that, it slows things down badly, as described above.
It sounds like using drawRect to draw static content is not a problem, because the system doesn't call your drawRect unless the contents change.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.