Slightly edited transcript of comments on one of the other answers:
I am drawing a color a hue based color picker (in draw rect a line for each hue value is drawn)
… Are you drawing 360 rectangles?
Yes, I am ….
I draw the images of 360 rectangles of different colors into the image of one UIImageView. than I release the rectangles. (I use a for loop for the rectangle allocation/releasing)
So, you are doing this 360 times:
- Create an image.
- Draw a rectangle into this image. (Or not, if step 1 loads the image from a file.)
- Draw that image into another image.
- Release the image.
And then you pass the image that you drew all the smaller images into to a UIImageView for the actual display?
It sounds like you're trying to cache this in the image, which should help after the first time if you do it right, but this doesn't need to be slow in the first place.
You already have a custom view. Drop the image view, and cut out all this rectangle-drawing (or image-drawing) code. If you have image files with the individual colored rectangles, delete them.
In your view's drawRect:
, create a gradient and draw that. Your drawRect:
will be three lines long and should be much, much, much faster.