1

I want resize the shapes draw on context by picking their endpoints. And also rotate it with its endPoints. Can anybody suggest me how can I do this with proper example?

My edited Question.

enter image description here

According to the image I have to rotate and scale the shapes by its Endpoint

Jane
  • 288
  • 1
  • 3
  • 18
  • 2
    Are you sure you want to do that? The normal gestures are to pinch-zoom and swivel, which doesn't require picking the corners. – Marcelo Cantos Oct 07 '11 at 12:42
  • 1
    Thanks for your comment, but I have to do the same functionality with Endpoints only :) I am editing my question. – Jane Oct 07 '11 at 13:06
  • 2
    Then I'll restate my question: why do you want to persist with an object manipulation metaphor designed for the mouse on a device that supports multi-touch? – Marcelo Cantos Oct 07 '11 at 13:15
  • Actually it is the requirement of my client that is why I have to do this things..:) – Jane Oct 08 '11 at 05:49
  • 1
    Would it not be possible to try and educate your client on why this is not a brilliant idea? Maybe mock up a better implementation and get them to try it? – Dolbz Oct 13 '11 at 09:30

1 Answers1

0

when the user touches the Endpoint, you can get the coordinates of the touch in touchesbegan: and the frame and transformation of the image. When you move, you get a new coordinate for the touch in touchesmoved:.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    self.touchStart = [[touches anyObject] locationInView:viewThatContainsImage];
    self.imageStartFrame = image.frame;
    self.imageTransformStart = image.transform;
    [super touchesBegan:touches withEvent:event];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint newTouchPoint = [[touches anyObject] locationInView:viewThatContainsImage];
    [super touchesMoved:touches withEvent:event];
}

With the starting frame, starting transformation and the starting point and current point, you can figure out the new size/angle change.

Aberrant
  • 3,423
  • 1
  • 27
  • 38
  • Thanks This is true for UIImage but I want to do the same for shapes which I have draw on context.See I have edited my question...:) – Jane Oct 13 '11 at 10:16
  • Ah, I see. Shapes cannot be moved though. It's like having paint on a canvas, you can't move the paint anymore, just draw over it. To move the shapes, you'll either have to remember all the points manually and draw the shapes at the right places, or have a UIView that represents an individual shape and deals with its own drawing. I strongly recommend the second option. – Aberrant Oct 13 '11 at 10:22
  • Thnaks for ur opnion bt in this link http://stuntsoftware.com/freeform/ one app is created same.They have use the drawKit for that which is MACOS framework.How can I convert it into ios? – Jane Oct 13 '11 at 11:13
  • I'm fairly sure that app uses seperate views for each shape as well, especially since they are calling their shapes objects. In stead of having one monstrously big UIview that would manage every single point, color, angle, length, gradients, etc, they'll have a bunch of views inside the big one, each remembering and drawing their own values. They use the same shapes system, but just for themselves. An extra plus is that the views don't draw when behind other (opaque) views, making your app faster. It's up to you whether you choose to go with this, I wish you good luck. – Aberrant Oct 13 '11 at 11:22