1 #import "NJViewController.h"2 3 @interfaceNjviewcontroller ()4@property (Weak, nonatomic) Iboutlet UIView *CustomView;5 6 @end7 8 @implementationNjviewcontroller9 Ten- (void) Viewdidload One { A [Super Viewdidload]; -Uipangesturerecognizer *pan =[[Uipangesturerecognizer alloc] init]; - [Self.customview Addgesturerecognizer:pan]; the - [Pan addtarget:self Action: @selector (Panview:)]; - } - +- (void) Panview: (Uipangesturerecognizer *) Pan - { + //The value returned is the point at which the finger is pressed. A //1 2 3) 4 5 atCgpoint point =[Pan TranslationInView:pan.view]; - -NSLog (@"Drag-and- drop event%@", Nsstringfromcgpoint (point)); -Cgpoint temp =Self.customView.center; -temp.x + =Point.x; -Temp.y + =Point.y; inSelf.customView.center =temp; - to [Pan Settranslation:cgpointzero InView:pan.view]; + } - the @end
iOS gesture recognition drag and drop