iphone - How to move resizableUIView from its corner in iOS? -


i want drag resizable uiview corner? on desktop click mouse button , hold on click , drag mouse transparent view visible this.

i want in project in iphone. want when user touch , drag finger 1 resizable transparent view visible.

i have done far on click on button view visible , resizable also. not solution, want on touch on iphone screen resizable uiview come.

any idea , suggestions highly welcome.

this code have done far:

- (void)viewdidload {   tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handletap:)]; tap.numberoftapsrequired = 1; [imagevw addgesturerecognizer:tap]; tap.delegate=self; pan=[[uipangesturerecognizer alloc]initwithtarget:self action:@selector(panaction:)]; [pan setminimumnumberoftouches:1]; [pan setmaximumnumberoftouches:2]; [pan setdelegate:self]; count=0; //    [pan minimumnumberoftouches:1]; //    [pan maximumnumberoftouches:2]; [imagevw addgesturerecognizer:pan]; }    -(void)handletap:(uipangesturerecognizer *)gesturerecognizer {  userresizableview = [[spuserresizableview alloc] init]; userresizableview.frame = cgrectmake(x,y,w,h); //uiview *content_view = [[uiview alloc] initwithframe:userresizableview.bounds]; //[content_view setbackgroundcolor:[uicolor whitecolor]]; imagevw1 = [[uiimageview alloc]initwithframe:userresizableview.bounds]; //imagevw1.image = [uiimage imagenamed:@"redacted2.jpg"]; imagevw1.backgroundcolor = [uicolor blackcolor]; imagevw1.userinteractionenabled=yes; imagevw1.autoresizessubviews = yes; imagevw1.alpha = 0.13;  // opacity userresizableview.contentview = imagevw1; //[content_view addsubview:imagevw1];  //userresizableview.contentview = content_view; userresizableview.delegate = self; [userresizableview showeditinghandles]; currentlyeditingview = userresizableview; lasteditedview = userresizableview;  // [self.view addsubview:userresizableview]; // [imagevw addsubview: dview]; [self.view addsubview: userresizableview]; [userresizableview release];  }  - (void)userresizableviewdidbeginediting:(spuserresizableview *)userresizableview1 {   width  =   userresizableview.frame.size.width;  height  =   userresizableview.frame.size.height;  width1 = width;  height1 = height;  width = width + width;  height = height + height; [currentlyeditingview hideeditinghandles]; currentlyeditingview = userresizableview1;   }  - (void)userresizableviewdidendediting:(spuserresizableview *)userresizableview1 {  lasteditedview = userresizableview1; x1 = x; y1 = y; x =  userresizableview.frame.origin.x; y = userresizableview.frame.origin.y;  } 

first have declare 2 global variables

cgpoint startpoint; bool _shouldresize; 

then have override 2 touch event methods in view given

1.touchesbegan

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {  cgpoint touchpoint = [[touches anyobject] locationinview:[self superview]];  /*   here have check user tap corner of view using method  cgrectcontainspoint(cgrect rect, touchpoint);   here parameter rect should corner of view   if(!cgrectcontainspoint(cgrect rect, touchpoint)) { // here user did not tap in specific rect. no need of resizing      _shouldresize = no;     return;  }   */  _shouldresize = yes;  startpoint = touchpoint;  } 

2.touchesmoved

- (void)touchesmoved:(nsset *)touches withevent:(uievent *)event {  if(!_shouldresize)     return;  cgpoint touchpoint = [[touches anyobject] locationinview:[self superview]];  cgfloat displacementx = touchpoint.x - startpoint.x; cgfloat displacementy = touchpoint.y - startpoint.y;  startpoint.x = touchpoint.x; startpoint.y = touchpoint.y;  cgrect frame = [self frame]; frame.size.width += displacementx; frame.size.height += displacementy;  [self setframe:frame];  } 

hope :)


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -