-(IBAction)Handeltap:(UIGestureRecognizer *)sender { if(sender.state==UIGestureRecognizerStateBegan) { tapPoint1 = [sender locationInView:sender.view]; NSLog(@"UIGestureRecognizerStateBegan and x=%d and y=%d",(int)tapPoint1.x,(int)tapPoint1.y); img1=[[UIImageView alloc]initWithImage:nil]; [img1 setBackgroundColor:[UIColor lightTextColor]]; CGRect rect1=CGRectMake((float)tapPoint1.x,(float)tapPoint1.y,50,20); NSLog(@"rect=%f and %f and %f and %f",rect1.origin.x,rect1.origin.y,rect1.size.width,rect1.size.height); [img1 setFrame:rect1]; [self.view addSubview:img1]; [self.view bringSubviewToFront:img1]; } if(sender.state==UIGestureRecognizerStateChanged) {tapPoint2 = [sender locationInView:sender.view];
add a touch gesture and paste this
UILongPressGestureRecognizer *ges11=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(Handeltap:)]; [self.view addGestureRecognizer:ges11];
Tanks to help me ..
source share