iphone - draw gradient orientation -


so have following code:

-

 (void) drawlineargradient:(cgrect) rect {     cgcontextref context = uigraphicsgetcurrentcontext();     cgcolorspaceref colorspace = cgcolorspacecreatedevicergb();     cgfloat locations[] = { 0.0, 0.3, 1.0 };      cgcolorref graycolor = [uicolor colorwithred:37/255.f green:37/255.f                                              blue:37/255.f alpha:1.0].cgcolor;      cgcolorref bluecolor = [uicolor colorwithred:23.0/255.0 green:171.0/255.0                                              blue:219.0/255.0 alpha:1.0].cgcolor;      nsarray *colors = [nsarray arraywithobjects: (id) graycolor, (id) graycolor, (id) bluecolor, nil];      cggradientref gradient = cggradientcreatewithcolors(colorspace,                                                          (cfarrayref) colors, locations);      cgpoint startpoint = cgpointmake(cgrectgetmidx(rect), cgrectgetminy(rect));     cgpoint endpoint = cgpointmake(cgrectgetmidx(rect), cgrectgetmaxy(rect));      cgcontextsavegstate(context);     cgcontextaddrect(context, rect);     cgcontextclip(context);     cgcontextdrawlineargradient(context, gradient, startpoint, endpoint, 0);     cgcontextrestoregstate(context);      cggradientrelease(gradient);     cgcolorspacerelease(colorspace); } 

what draw gradient top bottom, how can make draws left right?

change these 2 lines:

cgpoint startpoint = cgpointmake(cgrectgetmidx(rect), cgrectgetminy(rect)); cgpoint endpoint = cgpointmake(cgrectgetmidx(rect), cgrectgetmaxy(rect)); 

to:

cgpoint startpoint = cgpointmake(cgrectgetminx(rect), cgrectgetmidy(rect)); cgpoint endpoint = cgpointmake(cgrectgetmaxx(rect), cgrectgetmidy(rect)); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -