Search code examples
iosswiftxcodeswift5uiprogressview

How to size UIProgressView's progress image to the size of the entire progress view track


I know that you can set a UIProgressView's progressImage property to some image that you want to represent the "progress", but it seems that the image is only sized to the width of the progress only, not the entire progress view width. In other words, I was hoping to achieve an effect where the progress appeared to "unveil" the background image by having the progress image sized to the entire progress view container and as the progress grew, more and more of the progress image showed. Is this possible?


Solution

  • Yes, you can easily write a custom view that displays progress by gradually removing a mask whose presence erases an image (for instance). Thus to whatever extent the mask is removed, to that extent the image is shown.