Build a nice progress bar - iphone

I need some inspiration on how to build a nice progress bar for the iPhone.
What I want to build is a custom progress bar, as I've drawn here:
alt text http://img.skitch.com/20100317-tf185nscpf41u1xp3s6fqbhux6.png
My approach up to now is to use a PNG (gray in the figure above) with a transparent rounded rectangle. Through this rectangle, users see the moving bar. It would be nice to draw this bar with Quartz and give it a fancy animation (similar to the Mac OS X progress bars).
Any hints how to do this

you could use a couple nested UIViews and control the size of the childview and have different colors of backgrounds to show the progress or you could subclass the UIProgress bar like this example of the slide to unlock UISlider that has animation. The example is of a UISlider but the method used for animation could also be used on a progress bar without the difficulty of handling touches.
here is a link directly to the code from that discussion

Related

Give UISlider progress bar rounded corners [Swift]

I am wondering if anyone knows how to customize a UISlider to give the progress bar rounded corners (without Thumb Image) as shown in the following image:
What I want:
What I have now:
Thanks!
That isn't how a UISlider works, so can't customize in that way. Instead, you would have to build your own custom view from scratch in order to get that display. The drawing part is trivially easy; getting your view to act like a slider (that is, if you want it to respond to touches and dragging) is pretty easy too.

Animating a custom background image on a UINavigationBar

Since iOS5 there seems to be plenty of ways to add a custom background image to a navigation bar. I've tried using the appearance proxy, which works very well to change the appearance of all UINavigationBars application wide, and the setBackgroundImage:forBarMetrics: method for changing an individual navigation bar.
Is it possible to animate a change to the background image dynamically?
My application has two main states, and I wanted to fade the navigation bar between two colours to represent these two states. I haven't yet found a way to do this.
Thanks.

iPhone HUD style progress bar

I've been wanting to create a HUD style loading bar like the SMS app on the iPhone used to have but I don't know how to. I was wondering if anyone has done this before or if there is a tutorial somewhere for it? I just think it looks so nice and would like to use it rather than the built in loading progress bar.
It should be very simple to implement using Core Animation layers (the CALayer class).
The bar would be a layer with rounded corners and the fill could be drawn by a custom drawing method.

What is the best way to implement a widget like this in iPhone SDK?

alt text http://img696.imageshack.us/img696/4453/screenshot20100505at125.png
At first we thought of have a back bar and a front bar and simply grow the front bar as the bar progresses. But then we realized that the front bar cannot "stretch" because it has a flat end, and the flat end will be taller than the back bar when it reaches near the end.
How would you implement this bar in the iPhone SDK?
I would do the same as Sophtware but with a bit more sophistication, since the background below the progress bar also seems to be an image view, having a bit of gradient on right side.
From bottom to top, I would have:
1) at the very bottom - background of the progress bar, stationary. It can be larger than the progress bar area since it will have stuff sitting on top of it.
2) the progress bar rectangle with border, shadow, gradient etc - as Sopthware says, you would slide this left and right for desired "progress"
3) the top layer - the bezel around the progress bar, with a hole (transparent area) in the middle, from where both the progress bar and background would be.
EDIT: you mentioning the background being UIToolbar changes things a bit. The easiest way implementation-wise would actually to produce all the possible states of the widget as one monolithic image. At runtime, you would simply swap the images. The widget is sufficiently small that this would not have an impact on the app size, and should be fine if you don't want to do complex animation or anything like that.
There are other ways of doing it that would involve breaking the image into pieces, but as you mention, those will be more dependent on the UIToolbar color. Producing it as a monolithic image will work with any toolbar color.
You could use two image views. The top one would be everything with the progress part knocked out, which would have that area set to transparent. The second image view would be rectangle of the entire progress portion. Then just slide the progress part under the top view to get the desired affect.

UIBarButtonItem in middle of navbar?

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:
Right/Left/Middle - Custom Image and/or Text
Right/Left - Normal looking button with custom Image in it
Right/Left - Normal looking button with custom Text in it
By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.
My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.
I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.
The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?
*********** UPDATE **************
The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.
I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.
Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.
Put a flexible region on the left and right, they will offset each other causing anything between them to be centered