1

I am rotating the image on slider value -

I am using this code for rotation -

editingView.transform = CGAffineTransformRotate(editingView.transform,sliderVal);

its Rotating properly but if i am trying to move or resize after rotation,The editingView is resizing with unexpected behavior and view disappears from screen.

Please suggest me what i am doing wrong.

Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
San007
  • 762
  • 1
  • 9
  • 30

3 Answers3

0

Have a look at this question.

Since you do not show any code on how you do the move or resizing, I suspect you are not properly concatenating the transforms. Furthermore, after you did the rotation, a translation will possibly work on the rotated coordinate system, therefore leading to unexpected behaviour.

Community
  • 1
  • 1
Michael Rose
  • 7,770
  • 3
  • 22
  • 26
0

Well whenever you rotate a view which is inside a superview, you should preserve the position of the view. If you are not rotating any view across the origin then, you should first translate the view's origin to the superview's origin and then rotate and then again translate back to the original point.

  • Find the coordinate if the view you want to rotate with respect to its superview, say it (x,y).
  • Translate the view to the origin as;

    view.transform = CGAffineTransformMakeTranslation(x,y)

  • Rotate the view by some angle, say PI,

    view.transform = CGAffineTransformMakeRotation(PI)

  • After rotation translate back to the original point as;

    view.transform = CGAffineTransformMakeTranslation(-x,-y)

And that's it. It should work with all the different rotation.

Sandeep
  • 20,908
  • 7
  • 66
  • 106
  • this solves my problem of after rotation resize and move but its stop rotating,just flickering the view. – San007 Apr 16 '13 at 13:29
0

Changing transform value affecting the frame value of UIView. As Apple says:

Warning: If this property is not the identity transform, the value of the frame property is undefined and therefore should be ignored.

Apple docs

So, if you are moving or resizing your view using frame property, try do this with bounds, center properties

Julia
  • 2,105
  • 1
  • 16
  • 7