2

I would like to display the progress like the image(except the black background that is screen color). I am using progress view for this. Here user doesn't have chance to change the progress manually.

Please help me on this.



enter image description here



Noundla Sandeep
  • 3,334
  • 5
  • 29
  • 56
  • you could try what you get setting the `trackImage` and `progressImage` of the `UIProgressView`. But I guess that little circle might be a problem if the progress is low. So it could be easier to write your own progressView to do this. Or try customizing a `UISlider` which has the knob and set `userInteractionEnabled` to `NO` – robert Aug 20 '14 at 11:26
  • @robert I tried with trackimage and progressImage. but that is not reflecting. UISlider is also not working for this. – Noundla Sandeep Aug 20 '14 at 11:33
  • ok - seems like that doesn't work anymore since iOS7... so you can choose to do your own class, or subclass `UIProgressView` to correctly set the images and frames like mentioned here: http://stackoverflow.com/a/22322367/3659846 – robert Aug 20 '14 at 11:54
  • 1
    I found the solution here http://www.raywenderlich.com/21703/user-interface-customization-in-ios-6 – Noundla Sandeep Aug 20 '14 at 12:39
  • added the answer in question. – Noundla Sandeep Aug 21 '14 at 07:30

2 Answers2

2

This might help someone. I have implemented this behaviour with UISlider instead of UIProgressView. UISlider solves the problem.

UIImage *minImage = [[UIImage imageNamed:@"slider_minimum.png"]
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
UIImage *maxImage = [[UIImage imageNamed:@"slider_maximum.png"]
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
UIImage *thumbImage = [UIImage imageNamed:@"thumb.png"];

[self.uisliderObj setMaximumTrackImage:maxImage
    forState:UIControlStateNormal];
[self.uisliderObj setMinimumTrackImage:minImage
    forState:UIControlStateNormal];
[self.uisliderObj setThumbImage:thumbImage
    forState:UIControlStateNormal];

source is from this link

Noundla Sandeep
  • 3,334
  • 5
  • 29
  • 56
0

You will find a lot of simple codes on WWW.COCOACONTROLS.COM . You can check it.

If you want to customise on own you can also subclass UIPROGRESSBAR class

and change the trackImage and progressImage of the UIProgressView.

Chetan
  • 2,004
  • 1
  • 13
  • 21
  • The track and progress images can easily be set without subclassing via UIAppearance or directly from, say, a view controller. – Jesse Rusak Aug 20 '14 at 14:10
  • Thats true.. There are still more properties which you can set rather than always writing every time. So I suggested to subclass to make it a general category. Depends on developer point of view how to write and what to make. – Chetan Aug 21 '14 at 06:33
  • Yeah, you *can* make a subclass, but your statement that "you will have to subclass" is not accurate. – Jesse Rusak Aug 21 '14 at 19:06