ios - Why CAKeyframeAnimation didn't present after created? -
my code won't work.
- (cakeyframeanimation *)createanimation { cakeyframeanimation *animation = [cakeyframeanimation animationwithkeypath:@"path"]; //does @"path" mean path created below ? or path on layer? animation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; cgmutablepathref path = cgpathcreatemutable(); cgpathmovetopoint(path, null, width-100, 0); cgpathaddquadcurvetopoint(path, null, width+100, 300, width-100, height); cgpathaddquadcurvetopoint(path, null, width+20, 220, width-100, height); cgpathaddquadcurvetopoint(path, null, width+50, 230, width-100, height); // …… more code animation.path = path; animation.repeatcount = 10; animation.delegate = self; animation.duration = 2; cgpathrelease(path); return animation; }
this animation. have implement delegate animationdidstart
, didstop
. animation did executed.
then add animation custom calayer
. intend animate 1 path on layer. code layer:
draglayer = [[cashapelayer alloc] init]; draglayer.frame = cgrectmake(0, 0, width, height); draglayer.path = [self pathtoanimatewithx:0 andy:0]; // custom method create cgpathref draglayer.fillcolor = appcolor.cgcolor; draglayer.strokecolor = [uicolor redcolor].cgcolor ; draglayer.linewidth = 5; [self.layer addsublayer:draglayer]; [draglayer addanimation:[self createanimation] forkey:@"uposuuuition"];
i thought problem animated path has no color, , don't know how add after lot of searching (including apple's documentation).
the other problem how animate draglayer's own path instead of recreating it.
update: have read documentation again , cakeyframeanimation seems wrong way it.i have find other way it.thanks
the problem you're animating path
property of shape layer, want animate position
property. try instead:
- (cakeyframeanimation *)createanimation { cakeyframeanimation *animation = [cakeyframeanimation animationwithkeypath:@"position"]; ...
Comments
Post a Comment