ios - Cannot animate CALayer strokeColor -


i've been trying draw simple rectangle , animate edge color. tried using following link , still doesn't help. fixed changing layer's border color , animating same. worked fine.

is there kvo strokecolor because i'm getting working backgroundcolor of layer.

i'm on xcode 4.6 running ios sdk 6.1

this i've been doing:

cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetlinewidth(context, 2.0); cgcontextsetstrokecolorwithcolor(context, [uicolor bluecolor].cgcolor);  cabasicanimation *strokeanim = [cabasicanimation animationwithkeypath:@"strokecolor"]; strokeanim.fromvalue         = (id) [uicolor redcolor].cgcolor; strokeanim.tovalue           = (id) [uicolor greencolor].cgcolor; strokeanim.duration          = 3.0; strokeanim.repeatcount       = 0; strokeanim.autoreverses      = yes; [self.layer addanimation:strokeanim forkey:@"animatestrokecolor"];  cgcontextmovetopoint(context, 0, 0); cgcontextaddlinetopoint(context, squarelength, 0); cgcontextaddlinetopoint(context, squarelength, squarelength); cgcontextaddlinetopoint(context, 0, squarelength); cgcontextaddlinetopoint(context, 0, 0); cgcontextstrokepath(context); 

tl;dr; meant @"bordercolor"


unless did override + (class)layerclass in view (which doubt did) view's layer going calayer instance doesn't have strokecolor property.

you use cashapelayer shouldn't stroke since calayer has bordercolor property looking for.

so advice animate bordercolor instead.


not related question:

from code you've posted looks adding animation inside of views drawrect: implementation. method should used actual drawing , suggest move animation code somewhere else. method called every time view redraws , adding new animation.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -