Reputation: 2401
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.
Upvotes: 1
Views: 329
Reputation: 24753
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){
showCompletionImage();
}
}
}
private void showCompletionImage(){
var img = new UIImageView( UIImage.FromBundle("img"));
img.Frame = new System.Drawing.RectangleF(0,0,this.Frame.Width, this.Frame.Height);
this.AddSubview(img);
this.BringSubviewToFront(img);
}
}
Upvotes: 1
Reputation: 686
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.
Upvotes: 3