| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // TouchImageView.m
- // iSales-NPD
- //
- // Created by Ray on 2/18/16.
- // Copyright © 2016 United Software Applications, Inc. All rights reserved.
- //
- #import "TouchImageView.h"
- @implementation TouchImageView
- @synthesize delegate;
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self becomeFirstResponder];
- self.userInteractionEnabled=true;
-
-
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
- longPress.minimumPressDuration = 0.8; //定义按的时间
- [self addGestureRecognizer:longPress];
- // self.layer.borderColor = [UIColor darkGrayColor].CGColor;
- // self.layer.borderWidth = 1.0;
- }
- return self;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self becomeFirstResponder];
- self.userInteractionEnabled=true;
- self.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.layer.borderWidth = 1.0;
-
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
- longPress.minimumPressDuration = 0.8; //定义按的时间
- [self addGestureRecognizer:longPress];
- // Initialization code
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
-
- if(delegate && [delegate respondsToSelector:@selector(TouchImageViewOnTouche:)])
- [delegate TouchImageViewOnTouche:self];
- }
- -(void)longPress:(UILongPressGestureRecognizer*)gestureRecognizer{
- if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
-
- if(delegate && [delegate respondsToSelector:@selector(TouchImageViewOnLongPress:)])
- [delegate TouchImageViewOnLongPress:self];
-
- }
- }
- //- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event
- //{
- // // event
- //}
- @end
|