ios - CALayer custom drawing glitch -



ios - CALayer custom drawing glitch -

i'm working on glow effect calayer. i've created uiview category. , custom drawing gives me unusual animation:

please, check full code.

update: i've added code, think crucial.

- (void)setglowhidden:(bool)glowhidden { self.layer.maskstobounds = glowhidden; self.clipstobounds = glowhidden; if (self.glowlayer == nil) { self.glowlayer = [glowlayer layer]; self.glowlayer.frame = self.layer.bounds; self.glowlayer.parentview = self; self.glowlayer.maskstobounds = no; self.glowlayer.contentsgravity = kcagravitycenter; [self.layer addsublayer:self.glowlayer]; } //... [self.glowlayer setneedsdisplay]; [self.glowlayer performselector:@selector(setneedsdisplay) withobject:nil afterdelay:0.0]; } //... - (void)drawincontext:(cgcontextref)ctx { cgfloat delta = max(self.glowsize, self.innerglowsize); cgrect drawingrect = cgrectmake(-delta, -delta, cgrectgetwidth(self.parentview.frame) + 2 * delta, cgrectgetheight(self.parentview.frame) + 2 * delta); cgpoint offsetpoint = cgpointmake(-drawingrect.origin.x, -drawingrect.origin.y); self.frame = drawingrect; [self setneedslayout]; [self layoutifneeded]; uigraphicsbeginimagecontextwithoptions(drawingrect.size, no, 0.0f); // [self.parentview drawviewhierarchyinrect:rect afterscreenupdates:yes]; [self.parentview.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *textimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uigraphicspushcontext(ctx); cgcontextsavegstate(ctx); if (_glowsize > 0) { cgcontextsetshadow(ctx, cgsizezero, _glowsize); cgcontextsetshadowwithcolor(ctx, cgsizezero, _glowsize, _glowcolor.cgcolor); } [textimage drawatpoint:offsetpoint]; cgcontextrestoregstate(ctx); //... }

ios xcode core-graphics calayer

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -