iOS Drawing curve charts

Source: Internet
Author: User

-(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.