12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // YOUPAIDragEditView.m
- // VideoEditDemo
- //
- // Created by 刘志伟 on 2017/8/17.
- // Copyright © 2017年 刘志伟. All rights reserved.
- //
- #import "YOUPAIDragEditView.h"
- @interface YOUPAIDragEditView(){
- UIImageView *imgView;
- }
- @property (nonatomic ,assign) BOOL isLeft;
- @end
- @implementation YOUPAIDragEditView
- - (instancetype)initWithFrame:(CGRect)frame Left:(BOOL)left{
- self = [[YOUPAIDragEditView alloc] initWithFrame:frame];
- self.backgroundColor = [UIColor clearColor];
- UIView *backView = [[UIView alloc] initWithFrame:self.bounds];
- backView.backgroundColor = [UIColor clearColor];
- backView.alpha = 0.6;
- [self addSubview:backView];
- self.isLeft = left;
- [self youpaifinitSubviews];
-
- return self;
- }
- - (void)youpaifinitSubviews{
- CGFloat width = self.frame.size.width;
- CGFloat height = self.frame.size.height;
-
- CGRect imgFrame;
- if (self.isLeft) {
- imgFrame = CGRectMake(width-10, 0, 10, height);
- }
- else {
- imgFrame = CGRectMake(0, 0, 10, height);
- }
-
- imgView = [[UIImageView alloc] initWithFrame:imgFrame];
- imgView.image = [UIImage imageNamed:@"vqu_images_D_drag"];
- [self addSubview:imgView];
- }
- - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
- return [self youpaifpointInsideSelf:point];
- }
- - (BOOL)youpaifpointInsideSelf:(CGPoint)point{
- CGRect relativeFrame = self.bounds;
- CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
- return CGRectContainsPoint(hitFrame, point);
- }
- - (BOOL)youpaifpointInsideImgView:(CGPoint)point{
- CGRect relativeFrame = imgView.frame;
- CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
- return CGRectContainsPoint(hitFrame, point);
- }
- @end
|