#import "QYCustomView.h"
/*
#define HOR_SWIPE_MIN 20//level, when below this value, do not think he is a sweeping gesture
#define VAR_SWIPE_MAX 40//Vertical, set this error range, if greater than this value, sweep invalid
*/
@implementation Qycustomview
-(ID) Initwithcoder: (Nscoder *) Adecoder
{
self = [super Initwithcoder:adecoder];
if (self) {
Self.backgroundcolor = [Uicolor Purplecolor];
_moveview = [[UIView alloc] Initwithframe:cgrectmake (20, 20, 30, 30)];
_moveview.backgroundcolor = [Uicolor Redcolor];
[Self addsubview:_moveview];
}
return self;
}
When our event starts, this method is called when the finger is actually placed on the screen for touch.
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event
{
_moveview = [[UIView alloc]initwithframe:cgrectmake (0, 0, 30, 30)];
_moveview.backgroundcolor = [Uicolor Redcolor];
[Self addsubview:_moveview];
}
This method is called when we click on the screen and slide without lifting, so that this method is called continuously.
-(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event
{
Uitouch *tch = [touches anyobject];
Cgpoint currentpoint = [tch locationinview:self];
CGRect frame = self.moveView.frame;
Self.moveView.center = Currentpoint;
NSLog (@ "%s", __func__);
}
When our event is tuned to the bundle, it is actually called when the finger leaves the screen for touch.
-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event
{
}
/*
//
When our event is canceled, say: Finger click on the screen, suddenly call, this time, the phone priority is very high,
All events should be canceled. This method will be called
-(void) touchescancelled: (Nsset *) touches withevent: (Uievent *) event
//{
NSLog (@ "%s", __func__);
Self.startpoint = Cgpointzero;
//}
*/
/*
Only override Drawrect:if perform custom drawing.
An empty implementation adversely affects performance during animation.
-(void) DrawRect: (cgrect) rect
{
Drawing Code
Self.backgroundcolor = [Uicolor Orangecolor];
}
*/
@end