cocoa - Within CALayer, drawInContext: is called but does not update screen -


i trying draw custom calayer added sublayer elsewhere. custom calayer class has 1 variable:

float xscale = 0.5f; 

and overrides drawincontext: method:

    -(void) drawincontext:(cgcontextref)ctx {          nslog(@"method called xscale %f", xscale);          cgcontextsetfillcolorwithcolor(ctx, [nscolor redcolor].cgcolor);         cgcontextaddrect(ctx, cgrectmake(100 * xscale, 100, 50, 50));         cgcontextfillpath(ctx);     } 

to draw red square on screen. when class initialised in nsview elsewhere with:

heartlayer = [[heartcalayer alloc] init]; heartlayer.frame = cgrectmake(0, 0, self.frame.size.width, self.frame.size.height); [self.layer addsublayer:heartlayer]; [heartlayer setneedsdisplay]; 

the square drawn in correct place. when ask layer redraw with

heartlayer.xscale = 1.0f; [heartlayer setneedsdisplay]; 

the drawincontext: method called, , xscale variable updated, square doesn't change it's location. don't know why screen not updating. calayer being added sublayer? graphics context invalid somehow? related implicit animation of calayers? i've searched everywhere , @ wits end :(

thanks, kenneth


sorry answer own question: perhaps you'll waste less time me:

the problem implicit animation of calayer class. discussed in thread.

i added following override method custom calayer class:

- (id<caaction>)actionforlayer:(calayer *)layer forkey:(nsstring *)key {     return (id)[nsnull null]; } 

and square updated correctly.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -