ios - Draw UIPageControl Indicator With Core Graphics? -


i want draw following uipagecontrol indicator:

enter image description here

i have following code, results in:

enter image description here

if (ishighlighted) {     uibezierpath *ovalpath = [uibezierpath bezierpathwithovalinrect:cgrectmake(0, 0, 6, 6)];      [[uicolor blackcolor] setstroke];     [ovalpath stroke];     [ovalpath addclip];      uicolor *lightgradientcolor = [uicolor colorwithred:0.8 green:0.8 blue:0.8 alpha:1.0];     uicolor *darkgradientcolor = [uicolor colorwithred:0.1 green:0.1 blue:0.1 alpha:1.0];      cgfloat locations[2] = {0.0 ,1.0};     cfarrayref colors = (__bridge cfarrayref) [nsarray arraywithobjects:(id)lightgradientcolor.cgcolor,                (id)darkgradientcolor.cgcolor,                nil];     cgcolorspaceref colorspc = cgcolorspacecreatedevicergb();     cggradientref gradient = cggradientcreatewithcolors(colorspc, colors, locations);      cgcontextdrawlineargradient(context, gradient, cgpointmake(cgrectgetmaxx([ovalpath bounds]), 0), cgpointmake(0, cgrectgetmaxy([ovalpath bounds])), (cggradientdrawingoptions)null);      cgcolorspacerelease(colorspc);     cggradientrelease(gradient); } else {     uibezierpath *ovalpath = [uibezierpath bezierpathwithovalinrect:cgrectmake(0, 0, 6, 6)];     [[uicolor colorwithwhite:1 alpha:0.3] setfill];     [[uicolor whitecolor] setfill];     [ovalpath fill]; } 

but can't indicator in picture. how manage right result?

the example you're trying replicate really tiny. might find easier dissect if @ large version -- set simulator retina mode, or take screenshot on retina device, , blow up. (maybe post here, too?) also, don't think code first -- think you're drawing, worry code it.

what looks me you've got: both dots might built 3 concentric circles, of radius 2, 3, , 4 pt. white one: draw 4-pt-radius circle first in dark gray (or semi-transparent black) fill. on top of that, 3-pt-radius circle light-to-medium gray gradient fill (oriented vertically, not diagonally have). finally, draw inner 2-pt-radius circle no fill , 1pt gradient (lighter-to-light gray) stroke. take close @ dark circle , can come similar strategy drawing that.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -