猎豆优选

ZLBrushBoardImageView.m 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // ZLBrushBoardImageView.m
  3. // ZLPhotoBrowser
  4. //
  5. // Created by long on 2018/5/9.
  6. // Copyright © 2018年 long. All rights reserved.
  7. //
  8. #import "ZLBrushBoardImageView.h"
  9. @interface ZLPath : UIBezierPath
  10. @property (nonatomic, strong) UIColor *lineColor;
  11. @end
  12. @implementation ZLPath
  13. @end
  14. @interface ZLBrushBoardImageView () <UIGestureRecognizerDelegate>
  15. {
  16. ZLPath *_path;
  17. NSMutableArray *_paths;
  18. __weak UIImage *_originImage;
  19. }
  20. @end
  21. @implementation ZLBrushBoardImageView
  22. //- (instancetype)init
  23. //{
  24. // self = [super init];
  25. // if (self) {
  26. // UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
  27. // pan.delegate = self;
  28. // [self addGestureRecognizer:pan];
  29. //
  30. // _paths = [NSMutableArray array];
  31. // }
  32. // return self;
  33. //}
  34. //
  35. //- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  36. //{
  37. // return YES;
  38. //}
  39. //
  40. //- (void)panAction:(UIPanGestureRecognizer *)pan
  41. //{
  42. // if (!self.drawEnable) return;
  43. //
  44. // CGPoint curP = [pan locationInView:self];
  45. //
  46. // if (pan.state == UIGestureRecognizerStateBegan) {
  47. // _path = [[ZLPath alloc] init];
  48. // _path.lineWidth = 5;
  49. // _path.lineColor = self.drawColor;
  50. // [_path moveToPoint:curP];
  51. // [_paths addObject:_path];
  52. // }
  53. //
  54. // [_path addLineToPoint:curP];
  55. //
  56. // [self draw];
  57. //}
  58. //
  59. //- (void)draw
  60. //{
  61. // UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, _originImage.scale);
  62. // [_originImage drawInRect:self.bounds];
  63. //
  64. // for (ZLPath *path in _paths) {
  65. // path.lineCapStyle = kCGLineCapRound;
  66. // path.lineJoinStyle = kCGLineJoinRound;
  67. // [path.lineColor setStroke];
  68. // [path stroke];
  69. // }
  70. // self.image = UIGraphicsGetImageFromCurrentImageContext();
  71. //
  72. // UIGraphicsEndImageContext();
  73. //}
  74. //
  75. - (void)revoke
  76. {
  77. // if (_paths.count <= 0) return;
  78. //
  79. // [_paths removeLastObject];
  80. // [self draw];
  81. }
  82. //
  83. //- (void)setImage:(UIImage *)image
  84. //{
  85. // _originImage = image;
  86. // [super setImage:image];
  87. //}
  88. @end