-2

I want to make a progressView circle. I followed one sample code that was working with background color but now I want to use background image instead of the background color.

This is the current sample code : Sample Code

Please see this sample code and guide me on how to change background color to background image (There are two images in the project namely : background.png & front.png).

Thanks.

this is my code :

KKProgressTimer.m

- (void)setupParams {
    self.backgroundColor = [UIColor clearColor];

    self.frameWidth = 3;
    self.progressColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]];
    self.progressBackgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"front"]];
    self.circleBackgroundColor = [UIColor whiteColor];
}

when run project my background don't fit in my view!!!

user3797431
  • 393
  • 1
  • 5
  • 15

2 Answers2

0

The property is defined there for changing the background color @property(nonatomic, strong) UIColor *progressBackgroundColor; and is you want to use the image then UIColor class have method + (UIColor *)colorWithPatternImage:(UIImage *)image; you can use with your image.

self.circleBackgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]];
Retro
  • 3,985
  • 2
  • 17
  • 41
0

You can not change UIActivityView but you can replace it with a rotating UIImageView. Create a category and follow like this:

- (void) setRotation:(float)duration
{
    CABasicAnimation *rotation;
    rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    rotation.fromValue = [NSNumber numberWithFloat:0];
    rotation.toValue = [NSNumber numberWithFloat:(2*M_PI)];
    rotation.duration = duration; // Speed
    rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number.
    [self.layer addAnimation:rotation forKey:@"Spin"];
}

You can make an UIImageView and rotate it like this:

[self.imgProgress setRotation:1];
Vaibhav Saran
  • 12,848
  • 3
  • 65
  • 75