Reputation: 5117
In iphone the UIProgressView height is fixed, i need to create UIProgressView for height 40(variable height), how to write my custom code in drawRect method? i am new to Quartz drawing any samples available.
Thanks in advance.
Upvotes: 2
Views: 2909
Reputation: 26859
Actually, you may not need to subclass drawRect:
.
Presumably the images for your progress view are "stretchable" (i.e. they have fixed size left and right ends with a middle part that can be stretched)? You can create a stretchable image by loading a UIImage
, calling stretchableImageWithLeftCapWidth:topCapHeight:
to get an image you can assign to a UIImageView
. Then, when you resize the UIImageView
, the image redraws correctly automatically -- the left and right "caps" are drawn at the left and right end of the image view, and the middle part is stretched to fill the middle.
Your progress bar becomes a view that holds two UIImageView
s as children: one for the background and one for the filled progress bar. With clever use of the autoresizingMask
, you should only need to change the frame of the progress bar fill to update the display.
Upvotes: 1