YOUPAIDragEditView.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // YOUPAIDragEditView.m
  3. // VideoEditDemo
  4. //
  5. // Created by 刘志伟 on 2017/8/17.
  6. // Copyright © 2017年 刘志伟. All rights reserved.
  7. //
  8. #import "YOUPAIDragEditView.h"
  9. @interface YOUPAIDragEditView(){
  10. UIImageView *imgView;
  11. }
  12. @property (nonatomic ,assign) BOOL isLeft;
  13. @end
  14. @implementation YOUPAIDragEditView
  15. - (instancetype)initWithFrame:(CGRect)frame Left:(BOOL)left{
  16. self = [[YOUPAIDragEditView alloc] initWithFrame:frame];
  17. self.backgroundColor = [UIColor clearColor];
  18. UIView *backView = [[UIView alloc] initWithFrame:self.bounds];
  19. backView.backgroundColor = [UIColor clearColor];
  20. backView.alpha = 0.6;
  21. [self addSubview:backView];
  22. self.isLeft = left;
  23. [self youpaifinitSubviews];
  24. return self;
  25. }
  26. - (void)youpaifinitSubviews{
  27. CGFloat width = self.frame.size.width;
  28. CGFloat height = self.frame.size.height;
  29. CGRect imgFrame;
  30. if (self.isLeft) {
  31. imgFrame = CGRectMake(width-10, 0, 10, height);
  32. }
  33. else {
  34. imgFrame = CGRectMake(0, 0, 10, height);
  35. }
  36. imgView = [[UIImageView alloc] initWithFrame:imgFrame];
  37. imgView.image = [UIImage imageNamed:@"vqu_images_D_drag"];
  38. [self addSubview:imgView];
  39. }
  40. - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
  41. return [self youpaifpointInsideSelf:point];
  42. }
  43. - (BOOL)youpaifpointInsideSelf:(CGPoint)point{
  44. CGRect relativeFrame = self.bounds;
  45. CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
  46. return CGRectContainsPoint(hitFrame, point);
  47. }
  48. - (BOOL)youpaifpointInsideImgView:(CGPoint)point{
  49. CGRect relativeFrame = imgView.frame;
  50. CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
  51. return CGRectContainsPoint(hitFrame, point);
  52. }
  53. @end