views:

44

answers:

1

Hey all,

I've been using Core Plot to draw some charts for an iOS app I've been developing. While core plot is excellent as a charting application, it's a performance hog when it comes to any kind of user interaction. To get around this, I started doing a lot of the following:

    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

I would then swap out the view for the image of the view before starting my animations, which made them far smoother.

Since then, I've started using this idea more in my app. I haven't had much iOS experience before this project and haven't really looked at much source from more expert developers. I just wanted to look for some feedback - am I missing the point by taking this approach?

+1  A: 

I use this extensively in an OpenGLES animation framework I've been working on to render animations between views. I don't know that you're missing the point, but if you are, then I must be as well, as so long as it fits within what you want to do in your application, it seems to me like a good way to go about doing things.

jer
I guess missing the point was a poor choice of words. I guess I just meant, is this the kind of code that will be scoffed at by experienced objective c devs saying "well, why don't you use the standard approach and do x". Good to see I'm not the only one taking this approach.
johnw188
Been at this for 3 years myself, and with only rare cases do I scoff at my own code and keep doing it that way. :)
jer