following the last article of the heartbeat animation, today to implement a path based on the heartbeat path animation, so that a view along the path of movement.
 
Core Code 1-First draw the heart-shaped path through the DrawRect
 
-(void) DrawRect: (cgrect) Rect {//Drawing code//initialization Uibezierpath Uibezierpath *path = [Uibezierpath bezierpa
    TH];
    First set a starting point cgpoint StartPoint = Cgpointmake (RECT.SIZE.WIDTH/2, 120);
    Starting point as the path to the start [path Movetopoint:startpoint];
    Set an endpoint Cgpoint EndPoint = Cgpointmake (RECT.SIZE.WIDTH/2, rect.size.height-40);
    Set the first control point cgpoint controlPoint1 = Cgpointmake (100, 20);
    Set the second control point cgpoint controlPoint2 = Cgpointmake (0, 180);
    Add three Bezier curves [path addcurvetopoint:endpoint controlpoint1:controlpoint1 Controlpoint2:controlpoint2];
    Set another starting point [path movetopoint:endpoint];
    Set the third control point cgpoint ControlPoint3 = Cgpointmake (rect.size.width-100, 20);
    Set fourth control point Cgpoint controlPoint4 = Cgpointmake (rect.size.width, 180);
    Add three Bezier curves [path addcurvetopoint:startpoint controlpoint1:controlpoint4 Controlpoint2:controlpoint3];
    Set line width path.linewidth = 3; Set line section type Path.linecapstyle = Kcglinecapround
    Set Connection Type Path.linejoinstyle = Kcglinejoinround;
    Sets the brush color [[Uicolor Redcolor] set];
[Path stroke]; } 
2-Add Heart path to view 
    Heartview *heart = [[Heartview alloc] init];
    Heart.frame = CGRectMake (0, 0, screen_width, screen_height-screen_height);
    [Self.view Addsubview:heart];
 
3-Add trajectory path animation to animated view (red circle view) 
    Cakeyframeanimation *animation = [cakeyframeanimation animationwithkeypath:@ "position"];
    Set the path of the animation to the heart-shaped path
    Animation.path = Self.path.CGPath;
    Animation time interval
    animation.duration = 3.0f;
    The number of repetitions is the maximum
    animation.repeatcount = Flt_max;
    Animation.removedoncompletion = NO;
    Animation.fillmode = kcafillmodeforwards;
    Add an animation to the animated view
    [_demoview.layer addanimation:animation Forkey:nil];