-(void) drawline{ //view is the background of the curve view UIView *view = [[UIView alloc]initwithframe:cgrectmake (0, +)]; View.backgroundcolor = [Uicolor whitecolor]; [Self.view Addsubview:view]; First, Uibezierpath draw segment Uibezierpath *path = [Uibezierpath Bezierpath]; Four points cgpoint point = Cgpointmake (ten); Cgpoint point1 = Cgpointmake (n.); Cgpoint Point2 = Cgpointmake (a); Cgpoint Point3 = Cgpointmake (290, n); Nsarray *arr = [Nsarray arraywithobjects:[nsvalue valuewithcgpoint:point],[nsvalue ValueWithCGPoint:point1],[NSValue Valuewithcgpoint:point2],[nsvalue Valuewithcgpoint:point3], nil]; Nsindexset *set = [Nsindexset indexsetwithindexesinrange:nsmakerange (0, Arr.count)];
Second, this is the sentence to draw
[Arr enumerateobjectsatindexes:set options:0 usingblock:^ (nsvalue *pointvalue, Nsuinteger idx, BOOL *stop) {Cgpoint point = [Pointvalue cgpointvalue]; [Path Addlinetopoint:point]; (i) Rect polyline descriptive cgrect rect; rect.origin.x = point.x-1.5; RECT.ORIGIN.Y = point.y-1.5; Rect.size.width = 4; Rect.size.height = 4; (ii) RECT-ray representations//CGRect rect = CGRectMake (10, 10, 1, 1); Uibezierpath *arc= [Uibezierpath bezierpathwithovalinrect:rect]; [Path APPENDPATH:ARC]; }]; Third, Uibezierpath and Cashapelayer association cashapelayer *linelayer = [Cashapelayer layer]; Linelayer.frame = CGRectMake (0, 150, 320, 400); Linelayer.fillcolor = [Uicolor Redcolor]. Cgcolor; Linelayer.path = path. Cgpath; Linelayer.strokecolor = [Uicolor Redcolor]. Cgcolor; [View.layer Addsublayer:linelayer]; The following code for the additional//(a) Like a curtain pull, appear to have animated UIView *view1 = [[UIView Alloc]initwithframe:cgrectmakE (0, 100, 320, 400)]; View1.backgroundcolor = [Uicolor Whitecolor]; [Self.view Addsubview:view1]; [UIView animatewithduration:5 animations:^{view1.frame = CGRectMake (320, 100, 320, 400); }]; }
iOS Drawing curve charts