Draw UIImageView at multiple places in superview - iPhone OS
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 d开发者_开发技巧own. How can I reuse an image view?
Anthony
Make your own UIView subclass and then draw the images onto it yourself in the drawRect message. Look at this
How to draw an UIImage or directly in -drawRect:?
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];
}
精彩评论