Take the 2-minute tour ×

I have a progress bar which when it hits 100%, and if given a certain condition, I want to cover it with an image which is the same size as the progress bar. I'm not sure if I need a UIImageView or a UIImage. Do I then add it as a subview to my View that has the progress bar, and set the frame so that it matches the coordinates of the progress bar? I haven't done anything like this before.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

A better design would be to extend the UIProgressView class, like the following. I haven't tested the code, so make any adjustments as necessary:

public class CustomUIProgressView: UIProgressView {
    public CustomUIProgressView(){


    public override float Progress {
        get {
            return base.Progress;
        set {
            base.Progress = value;
            if (value==1.0){

    private void showCompletionImage(){
        var img = new UIImageView( UIImage.FromBundle("img"));
        img.Frame = new System.Drawing.RectangleF(0,0,this.Frame.Width, this.Frame.Height);

share|improve this answer
Sorry, what's FromBundle? I haven't seen that before. Very cool solution. –  Driss Zouak Mar 10 '11 at 0:40
The bundle is the zipfile that is your app. The FromBundle() method automatically tries to load the image for the proper screen resolution you have, so you can have for example cat.png and cat@2x.png in your dir, and on the method you can just say UIImage.FromBundle("cat"). Pretty useful. –  Eduardo Scoz Mar 10 '11 at 1:06
add comment

Create the UIImageView with the new image overlay-ed on top of the progress bar. Just set the .hidden property to YES initially and when the conditions are met, change it to NO, thus making the overlaid UIImageView visible.

share|improve this answer
add comment

Your Answer


