0

I'm scaling an object as below:

CGAffineTransform newTransform = CGAffineTransformScale(self.graphicView.transform, (graphicViewSize.width + resizeValue) / graphicViewSize.width, (graphicViewSize.height + resizeValue) / graphicViewSize.height);

This scales correctly, however it moves the origin position of the view. What is the best way to move it back? Best to do a translate? What is a nice way to do this, is it possible translate and scale at the same time so this happens?

Charan
  • 4,940
  • 3
  • 26
  • 43
Ser Pounce
  • 14,196
  • 18
  • 84
  • 169
  • cf. http://stackoverflow.com/questions/5983090/rotating-an-image-context-cgcontextrotatectm-causing-it-to-become-blank-why/5983173#5983173 – nielsbot Oct 02 '12 at 07:16

2 Answers2

0

Change the layer's anchor point property. By default, it is set to the center so the view will scale in all directions, but you can change it to the corners to maintain one of them in a fixed location.

borrrden
  • 33,256
  • 8
  • 74
  • 109
0

Use this:

CGAffineTransform newtransform = CGAffineTransformIdentity;

This should work if your intial view was at (0,0) before scaled or rotated.

Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132