3

i want to obtain the progress bar like in the image below:

Striped loading progress bar with triangle at the end

Here is what i've done so far, with the help of the project from github https://github.com/iluuu1994/ITProgressBar-iOS, so here is what i attempted:

     UIGraphicsBeginImageContextWithOptions(CGSizeMake(42, self.frame.size.height-10), NO, 0.f);
        UIColor* color = [UIColor colorWithRed:251.0f/255.0f green:235.0f/255.0f blue:77.0f/255.0f alpha:1.0f];

        UIBezierPath *bezierPath = [UIBezierPath new];
        [bezierPath moveToPoint:CGPointMake(0.0, 0.0)];
        [bezierPath addLineToPoint:CGPointMake(23, 0)];
        [bezierPath addLineToPoint:CGPointMake(42, 29)];
        [bezierPath addLineToPoint:CGPointMake(23, 70)];
        [bezierPath addLineToPoint:CGPointMake(0, 70)];
        [bezierPath addLineToPoint:CGPointMake(20, 29)];
        [bezierPath addLineToPoint:CGPointMake(0, 0)];
        [bezierPath closePath];
        [color setFill];
        [bezierPath fill];

    }];
}

I tried to override the drawRect method from UIView but nothing seems to work, so i fought to apply a mask to the layer I'am using.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
Andrew M.
  • 31
  • 3
  • Call [view setNeedsDisplay]; once you update the progress value to update UI. – Avijit Nagare Jan 18 '17 at 13:50
  • From the code you've provided in your question, it appears that all you're doing is drawing some stuff into an image context. If you want to do this in `drawRect:` you should remove the `UIGraphicsBeginImageContextWithOptions` line and draw to the context that is automatically set up by UIKit when it calls the `drawRect:` method. – Dave Weston Jan 20 '17 at 23:16

0 Answers0