ios - CoreAnimation rotating an object and changing it's position at the same time -
what i'm trying rotate view left , right , @ same time move it's position , down.
here's code have:
cgaffinetransform leftwobble = cgaffinetransformrotate(cgaffinetransformidentity, radians(-12.0)); cgaffinetransform rightwobble = cgaffinetransformrotate(cgaffinetransformidentity, radians(12.0)); flyingguy.transform = leftwobble; // starting point [uiview beginanimations:@"wobble" context:flyingguy]; [uiview setanimationrepeatautoreverses:yes]; [uiview setanimationrepeatcount:1000]; [uiview setanimationduration:1.3]; [uiview setanimationdelegate:self]; [uiview setanimationdidstopselector:@selector(wobbleended:finished:context:)]; flyingguy.transform = rightwobble; cgrect frame = flyingguy.frame; frame.origin.y += 10; [flyingguy setframe:frame]; [uiview commitanimations]; - (void)wobbleended:(nsstring *)animationid finished:(nsnumber *)finished context:(void *)context { if ([finished boolvalue]) { uiview* item = (uiview *)context; item.transform = cgaffinetransformidentity; } }
with current code, view size changes moves or down. suggestions?
don't set or frame after have set transform!
from docs:
warning if
transform
property not identity transform, value of property undefined , therefore should ignored.
what should instead
change center
property of view. changing position anyway , safe when have transform applied.
Comments
Post a Comment