i'm trying animate rotation of nsview around center, keeps shifting side side during rotation. causing this?
-(void)startrefreshanimation { [nsanimationcontext begingrouping]; [[nsanimationcontext currentcontext] setduration:1.0]; [[nsanimationcontext currentcontext] settimingfunction:[camediatimingfunction functionwithname:kcamediatimingfunctionlinear]]; [nsanimationcontext currentcontext].completionhandler = ^{ [self startrefreshanimation]; }; [[view animator] setframecenterrotation:previousrotation - 90.0]; previousrotation += -90.0; [nsanimationcontext endgrouping]; }
shift during rotation:
shift down during rotation:
from documentation:
if application has altered layer’s anchorpoint property, behavior undefined. sending message view not managing core animation layer causes exception.
is view managing calayer unmodified anchor point?
edit
i setup similar code @ got exact same results. no adjust of origin or anchor point resolve problem. theory particular method contains bugs (does autolayout), or works in way don't anticipate. achieved correct effect using cabasicanimation
.
/* setup */ .... _view.layer.anchorpoint = cgpointmake(0.5f, 0.5f); _view.layer.position = ... [self startrefreshanimation]; } - (void)animationdidstop:(caanimation *)anim finished:(bool)flag { [self startrefreshanimation]; } -(void)startrefreshanimation { cabasicanimation *anim2 = [cabasicanimation animationwithkeypath:@"transform.rotation"]; anim2.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctionlinear]; anim2.fromvalue = [nsnumber numberwithfloat:previousrotation * (m_pi / 180.0f)]; anim2.tovalue = [nsnumber numberwithfloat:(previousrotation + 90.0f) * (m_pi / 180.0f)]; previousrotation = previousrotation + 90.0f; anim2.duration = 1.0f; anim2.delegate = self; [_view.layer addanimation:anim forkey:@"transform"]; }
Comments
Post a Comment