CGPath Animation -
I need some sample code, where I can animate a curve / arc path, which is animated Need to draw a full circle?
strong> update : To better address this problem, simply create a circular path and animate the strokeindex property of the cache player from 0.08 to 1.0f Take a look at this answer from the wet:
Original Answer :
You can use a CAKeyframeAnimation and create a core graphics path. This code animates a layer in a parabolic pattern, but you can customize it to attract a circle.
- (CAAnimation *) path animation; {CGMutablePathRef path = CGPathCreateMutable (); CGPathMoveToPoint (path, zero, 50.0,120.0); CGPathAddCurveToPoint (path, NULL, 50.0,275.0, 150.0275.0, 150.0120.0); CGPathAddCurveToPoint (path, NULL, 150.0275.0, 250.0.275.0, 250.0.120.0); CGPathAddCurveToPoint (path, NULL, 250.0,275.0, 350.0.275.0, 350.0.120.0); CGPathAddCurveToPoint (path, NULL, 350.0,275.0, 450.0275.0, 450.0120.0); CAKeyframeAnimation * Animation = [CAKeyframeAnimation with animation: @ "status"]; [Animation setpath: path]; [Animation set duration: 3.0]; [Animation setsupervers: yes]; CFRelease (path); Return animation; }
Comments
Post a Comment