views:

72

answers:

2

I'm creating a custom progress bar and I've spliced it up into 1px images. If the progress bar were 100px wide then I would need 100 UIImageViews to fill the progress bar. The problem is this very quickly slows the iPhone down. How can I reuse an image view?

Anthony

+1  A: 

Make your own UIView subclass and then draw the images onto it yourself in the drawRect message. Look at this

http://stackoverflow.com/questions/1663815/how-to-draw-an-uiimage-or-directly-in-drawrect

Lou Franco
A: 

Create The imageView in Xib (Not in View)

Create it's IBOutlet (Suppose Named MyImage) And Try

For(int i=0;i<100;i++) 
{
    UIImageView *img=[[UIImageView alloc]init];
    img.frame=CGRectMake(i,100,1,1);
    img.image=MyImage.image;
    [self.View addSubView:img];

}
Ashish Mathur
This is exactly how I'm doing it. I don't want 100 UIImageView instances. It's harsh on the memory.