VLCLinearProgressIndicator.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*****************************************************************************
  2. * VLCLinearProgressIndicator.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCLinearProgressIndicator.h"
  13. @implementation VLCLinearProgressIndicator
  14. - (void)drawRect:(CGRect)rect
  15. {
  16. self.backgroundColor = [UIColor clearColor];
  17. CGContextClearRect(UIGraphicsGetCurrentContext(), rect);
  18. UIColor *drawingColor = [UIColor colorWithRed:.792 green:.408 blue:.0 alpha:.9];
  19. UIBezierPath* bezierPath = [UIBezierPath bezierPath];
  20. float progress_width = self.progress * rect.size.width;
  21. [bezierPath moveToPoint:CGPointMake(progress_width - rect.size.height + 3., 2.)];
  22. // Create our triangle
  23. [bezierPath addLineToPoint:CGPointMake(progress_width - (rect.size.height/2), rect.size.height - 5.)];
  24. [bezierPath addLineToPoint:CGPointMake(progress_width - 3., 2.)];
  25. [bezierPath closePath];
  26. // Set the display for the path, and stroke it
  27. bezierPath.lineWidth = 6.;
  28. [drawingColor setStroke];
  29. [bezierPath stroke];
  30. [drawingColor setFill];
  31. [bezierPath fill];
  32. }
  33. @end