osx - Layer size/bounds during a core animation -
osx - Layer size/bounds during a core animation -
i working on mac app mac os x 10.6+ , need redraw contents of caopengllayer while animation occurring. think i've read on necessary parts, not working me. set animation follows:
[catransaction setanimationduration:slide_duration]; cabasicanimation *drawanim = [cabasicanimation animationwithkeypath:@"drawit"]; [drawanim setfromvalue:[nsnumber numberwithfloat:0]]; [drawanim settovalue:[nsnumber numberwithfloat:1]]; [drawanim setduration:slide_duration]; [chartview.chartviewlayer addanimation:drawanim forkey:@"drawit"]; chartframe.origin.x += controlframe.size.width; chartframe.size.width -= controlframe.size.width; chartview.chartviewlayer.frame = cgrectmake(chartframe.origin.x, chartframe.origin.y, chartframe.size.width, chartframe.size.height);
the drawit property custom property purpose called draw layer during successive animation frames. order work, have add together chartviewlayer's class:
+ (bool)needsdisplayforkey:(nsstring *)key { if ([key isequaltostring:@"drawit"]) { homecoming yes; } else { homecoming [super needsdisplayforkey:key]; } }
so seems working fine. however, need current (animated) size of layer before drawing it. i've found various conflicting info on how out of presentation layer. here i've tried when layer's:
drawincglcontext:(cglcontextobj)glcontext pixelformat:(cglpixelformatobj)pixelformat forlayertime:(cftimeinterval)timeinterval displaytime:(const cvtimestamp *)timestamp
method called during animation. i've tried getting size using kvc, , querying either frame or bounds.
calayer *presentationlayer = [chartviewlayer presentationlayer]; //bounds.size.width = [[[chartviewlayer presentationlayer] // valueforkeypath:@"frame.size.width"] intvalue]; //bounds.size.height = [[[chartviewlayer presentationlayer] // valueforkeypath:@"frame.size.height"] intvalue]; //bounds.size = presentationlayer.bounds.size; bounds.size = presentationlayer.frame.size; nslog(@"size during animation: %f, %f", bounds.size.width, bounds.size.height);
in cases, returned value end result of animation rather transitional values. understanding using presentationlayer should give transitional values.
so broken or missing critical step? help.
osx core-animation presentation-layer
Comments
Post a Comment