objective c - How can I rotate and move a UIView at the same time? -
i'm trying make uiview move , rotate @ same time.
here's code:
_viewtodrag.frame = cgrectmake(x, y, size, width); _viewtodrag.transform = cgaffinetransformmakerotation(-m_pi_2 * multiplier));
as multiplier increases (0.0 .. 1.0) view stretches beyond logic.
this post seems answer question: rotating , moving uiimageview (cocoatouch)
but, since i'm code-dyslexic , bit retarded can explain translates code:
change "center" property instead.
i have made comment reputation doesn't allow it.
always consult documentation. apple says, in big box exclamation mark graphic next it, in section on frame
:
warning: if transform property not identity transform, value of property undefined , therefore should ignored.
underneath centre
says:
the center specified within coordinate system of superview , measured in points. setting property changes values of frame properties accordingly.
so answer link incorrect. given one-sentence nature no reference sources, author tried once, on version of ios happened have installed, looked worked , jumped straight unsupported conclusion.
the other answer correct. need build translation transform. throwing in use of cgaffinetransformtranslate
.
edit: so, set transform translation of (1000, 0) , rotation of -m_pi/2:
_viewtodrag.transform = cgaffinetransformrotate( cgaffinetransformmaketranslation(1000.0, 0.0), -m_pi_2);
Comments
Post a Comment