Нет описания

QBCheckmarkView.m 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // QBCheckmarkView.m
  3. // QBImagePicker
  4. //
  5. // Created by Katsuma Tanaka on 2015/04/03.
  6. // Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
  7. //
  8. #import "QBCheckmarkView.h"
  9. @implementation QBCheckmarkView
  10. - (void)awakeFromNib
  11. {
  12. [super awakeFromNib];
  13. // Set default values
  14. self.borderWidth = 1.0;
  15. self.checkmarkLineWidth = 1.2;
  16. self.borderColor = [UIColor whiteColor];
  17. self.bodyColor = [UIColor colorWithRed:(20.0 / 255.0) green:(111.0 / 255.0) blue:(223.0 / 255.0) alpha:1.0];
  18. self.checkmarkColor = [UIColor whiteColor];
  19. // Set shadow
  20. self.layer.shadowColor = [[UIColor grayColor] CGColor];
  21. self.layer.shadowOffset = CGSizeMake(0, 0);
  22. self.layer.shadowOpacity = 0.6;
  23. self.layer.shadowRadius = 2.0;
  24. }
  25. - (void)drawRect:(CGRect)rect
  26. {
  27. // Border
  28. [self.borderColor setFill];
  29. [[UIBezierPath bezierPathWithOvalInRect:self.bounds] fill];
  30. // Body
  31. [self.bodyColor setFill];
  32. [[UIBezierPath bezierPathWithOvalInRect:CGRectInset(self.bounds, self.borderWidth, self.borderWidth)] fill];
  33. // Checkmark
  34. UIBezierPath *checkmarkPath = [UIBezierPath bezierPath];
  35. checkmarkPath.lineWidth = self.checkmarkLineWidth;
  36. [checkmarkPath moveToPoint:CGPointMake(CGRectGetWidth(self.bounds) * (6.0 / 24.0), CGRectGetHeight(self.bounds) * (12.0 / 24.0))];
  37. [checkmarkPath addLineToPoint:CGPointMake(CGRectGetWidth(self.bounds) * (10.0 / 24.0), CGRectGetHeight(self.bounds) * (16.0 / 24.0))];
  38. [checkmarkPath addLineToPoint:CGPointMake(CGRectGetWidth(self.bounds) * (18.0 / 24.0), CGRectGetHeight(self.bounds) * (8.0 / 24.0))];
  39. [self.checkmarkColor setStroke];
  40. [checkmarkPath stroke];
  41. }
  42. @end