1

I have a UIProgressView that has been customised with a progress and track image. I also customised the size of the progress view. This works fine in iOS 6. I am facing problems getting this to work in iOS7.

_progress.progressViewStyle = UIProgressViewStyleBar;
_progress.trackImage = [UIImage imageNamed:@"summary-progress-track.png"];
_progress.progressImage = [UIImage imageNamed:@"summary-progress.png"];
_progress.frame = CGRectMake(50, 50, 100, 10);

Not only is the height being ignored but the custom images do not get applied. I just get a blue tinted progress bar like this:

image

I think the default tint colour is somehow overriding the progress images. I have also tried setting this with UIAppearance but it did not work.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIProgressView appearance] setProgressImage:[UIImage imageNamed:@"summary-progress.png"]];
    [[UIProgressView appearance] setTrackImage:[UIImage imageNamed:@"summary-progress-track.png"]];

    return YES;
}
Imran
  • 1,488
  • 1
  • 15
  • 36

4 Answers4

0

Personally I use the MPProgressHUD for all progress tracking on a view. Here's the link to the download https://github.com/jdg/MBProgressHUD

The usage is as simple as it get. Here's a tutorial you might like to check out.

http://code.tutsplus.com/tutorials/ios-sdk-uiactivityindicatorview-and-mbprogresshud--mobile-10530

The MPProgressHUD has a specific method to show custom images.

  • Thanks for the suggestion, I am already using MBPrgress hud but in a different context. I still would like to be able to customise the UIProgressView for a different use case. – Imran Feb 23 '14 at 12:20
0

This should be helpful if you have not already seen this.

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIProgressView.html#//apple_ref/doc/uid/TP40012857-UIProgressView-SW1

the blue color is the default tint color for the control in iOS7 that gets applied.

Preson
  • 244
  • 2
  • 8
0

Found a solution. If anyone else is stuck on this check out this answer and suggested code to workaround the issue: UIProgressView custom track and progress images in iOS 7.1

Community
  • 1
  • 1
Imran
  • 1,488
  • 1
  • 15
  • 36
0

I print the progress's subviews and find that one of them's frame width is 0,

so after

    [_videoProgressView setProgress:progress animated:NO];

reset the track and progress images

    UIImageView *trackImageView = _videoProgressView.subviews.firstObject;
    UIImageView *progressImageView = _videoProgressView.subviews.lastObject;
    CGRect trackProgressFrame = trackImageView.frame;
    trackProgressFrame.size.height = _videoProgressView.frame.size.height;
    trackImageView.frame = trackProgressFrame;
    progressImageView.frame = trackProgressFrame;
    progressImageView.image = progressImage;
    trackImageView.image = trackImage;
lieyunye
  • 9
  • 1