How can I change the color as well as size of UIProgressBar in iPhone SDK
Assuming you mean a UIProgressView
, you can resize it as you would any other view, by setting the frame:
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
[progressView setFrame:CGRectMake(0,0,320,10)];
or if you're using the default style, you can set the frame in the init method:
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0,0,320,10)];
As far as I know, the color of a UIProgressView
cannot be changed. You'll probably have to roll your own view for that.
You could probably also hack one together using an image that looks like the progress bar at it's smallest size and then create a stretchable image with it.
UIImage *progressBarImg= [someImage stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
Then you could set the image as the backgroundImage for a disabled UIButton and animate the button width incrementally to indicate progress. I haven't tried this, but I think it would work.
As Can noted, there is very little customization available for UIProgressView... pretty sucky. The solution I just implemented was to hack a UISlider. Here's the inspiration, from Apple's support forum.
Once this is setup and added to your UIView, use your custom method to set the value of the slider to the value you would normally have assigned to the UIPRogressView's progress.