Question

I' m trying to customize UIProgressView with custom progress image. But it is stretched incorrectly. So i have a custom progress image : enter image description here

its dimensions are 75x18 pixels. And I have a track which length is 270 points. But when I set my progress image its corner radius after filling the track became wrong. I tried to set resizableImageWithCapInsets: UIEdgeInsetsMake (0,0,0,1) but then image began to repeat and not to stretch. How can I fix this?

Was it helpful?

Solution

UIEdgeInsetsMake protects the pixels at the given values.

Red marker shows the stretchable area for UIEdgeInsetsMake(8.0, 10.0, 8.0, 10.0) (top, left, bottom, right)

enter image description here

Another thing is, always name your retina images properly even if you don't use the non retina versions for the older devices, like imageName@2x.png. Otherwise it will mess up it's scale.

And call it like this without the retina suffix:

[[UIImage imageNamed:@"g21hU.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(8.0, 10.0, 8.0, 10.0)]

Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top