开发者

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];

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜