VLCCircularProgressIndicator.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // VLCCircularProgressIndicator.m
  3. // AspenProject
  4. //
  5. // Created by Felix Paul Kühne on 12.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCCircularProgressIndicator.h"
  11. @implementation VLCCircularProgressIndicator
  12. - (void)drawRect:(CGRect)rect
  13. {
  14. self.backgroundColor = [UIColor clearColor];
  15. CGContextClearRect(UIGraphicsGetCurrentContext(), rect);
  16. CGFloat startAngle, endAngle = 0.;
  17. startAngle = M_PI * 1.5;
  18. endAngle = startAngle + (M_PI * 2);
  19. UIBezierPath* bezierPath = [UIBezierPath bezierPath];
  20. // Create our arc, with the correct angles
  21. [bezierPath addArcWithCenter:CGPointMake(rect.size.width / 2, rect.size.height / 2)
  22. radius:(rect.size.width / 2) - 6
  23. startAngle:startAngle
  24. endAngle:(endAngle - startAngle) * self.progress + startAngle
  25. clockwise:YES];
  26. // Set the display for the path, and stroke it
  27. bezierPath.lineWidth = 6.;
  28. [[UIColor grayColor] setStroke];
  29. [bezierPath stroke];
  30. }
  31. @end