iphone - How to add curve at two point joint using coreGraphics? -


i'm working on creating sine chart using core-graphics. done thing drawing chart , working need want add curve @ 2 point joint.

my chart looks below image:

example chart

i need draw line in below image don't know how:

chart want generate

can me out issue?

my drawrect code below

- (void)drawrect:(cgrect)rect {     [self setclearscontextbeforedrawing: yes];      cgcontextref context = uigraphicsgetcurrentcontext();       cgcolorref backcolorref = [uicolor blackcolor].cgcolor;     cgfloat backlinewidth = 2.f;     cgfloat backmiterlimit = 0.f;      cgcontextsetlinewidth(context, backlinewidth);     cgcontextsetmiterlimit(context, backmiterlimit);      cgcontextsetshadowwithcolor(context, cgsizemake(3, 5), 8, backcolorref);      cgcontextsetlinejoin(context, kcglinejoinround);      cgcontextsetlinecap(context, kcglinecapround );      cgcontextsetblendmode(context, kcgblendmodenormal);      cgcontextsetstrokecolorwithcolor(context, [uicolor whitecolor].cgcolor);        int x = 320 ;     int y = 180 ;      (int i=0; i<vdesc.count; i++)     {          cgpoint bpoint = cgpointmake(30, y);         cgpoint epoint = cgpointmake(x, y);          uilabel *label = [[uilabel alloc]initwithframe:cgrectmake(0, 0, 40, 30)];         [label setcenter:cgpointmake(bpoint.x-15, bpoint.y-30)];         [label settextalignment:uitextalignmentcenter];         [label setbackgroundcolor:[uicolor clearcolor]];         [label settextcolor:[uicolor whitecolor]];         [label settext:[vdesc objectatindex:i]];         [self addsubview:label];          cgcontextmovetopoint(context, bpoint.x, bpoint.y-30);         cgcontextaddlinetopoint(context, epoint.x, epoint.y-30);          y -= 30;      }     nslog(@"%d",hdesc.count);     (int i=0; i<hdesc.count; i++)     {          uilabel *label = [[uilabel alloc]initwithframe:cgrectmake(i*vinterval+5, 150, 30, 30)];         [label settextalignment:uitextalignmentcenter];         [label setbackgroundcolor:[uicolor clearcolor]];         [label settextcolor:[uicolor whitecolor]];         label.numberoflines = 1;         label.adjustsfontsizetofitwidth = yes;         label.minimumfontsize = 1.0f;         [label settext:[hdesc objectatindex:i]];          [self addsubview:label];     }        cgcolorref pointcolorref = [uicolor colorwithred:24.0f/255.0f green:116.0f/255.0f blue:205.0f/255.0f alpha:1.0].cgcolor;     cgfloat pointlinewidth = 1.5f;    // cgfloat pointmiterlimit = 5.0f;      cgcontextsetlinewidth(context, pointlinewidth);    // cgcontextsetmiterlimit(context, pointmiterlimit);       cgcontextsetshadowwithcolor(context, cgsizemake(3, 5), 8, pointcolorref);      cgcontextsetlinejoin(context, kcglinejoinround);      cgcontextsetlinecap(context, kcglinecapround );      cgcontextsetblendmode(context, kcgblendmodenormal);      cgcontextsetstrokecolorwithcolor(context, [uicolor whitecolor].cgcolor);      if (array1.count!=0)     {         cgpoint p1 = [[array1 objectatindex:0] cgpointvalue];         //int = 1;         cgcontextmovetopoint(context, p1.x, 380-p1.y);  //         cgcontextaddcurvetopoint(context, 0, 50, 300, 250, 300, 400);         (int i=0; i<[array1 count]; i++)         {             p1 = [[array1 objectatindex:i] cgpointvalue];             cgpoint gopoint = cgpointmake(p1.x, 430-p1.y*vinterval/20);               cgcontextaddlinetopoint(context, gopoint.x, gopoint.y);             uibutton *bt = [uibutton buttonwithtype:uibuttontypecustom];              [bt setbackgroundcolor:[uicolor redcolor]];              [bt setframe:cgrectmake(0,0,3,3)];             [bt setcenter:gopoint];             [self addsubview:bt];         }      }     else     {         nslog(@"empty");     }     cgcontextstrokepath(context);     } 

bezier path start can download sample code here, , curve u can use [path addquadcurvetopoint:nextpoint controlpoint:curvepoint]; method , method u can read here


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -