iOS UISegmentedControl with image overlaps by tint color -


i have problem uisegmentedcontrol image. when put image text on in segment tintcolor paints image , text. can it?

setting uiimage in segment

uiimage *tmp = [uiimage imagenamed:@"uisegmentedcontrol-active"];     uiimage *imagewithtext = [uiimage imagefromimage:tmp string:@"20" color:[uicolor whitecolor]];     [self.segmentedcontrol setimage:imagewithtext forsegmentatindex:0]; 

imagefromimage code:

+ (id) imagefromimage:(uiimage*)image string:(nsstring*)string color:(uicolor*)color {     uifont *font = [uifont systemfontofsize:16.0];     cgsize expectedtextsize = [string sizewithattributes:@{nsfontattributename: font}];     int width = image.size.width + 5;     int height = max(expectedtextsize.height, image.size.width);     cgsize size = cgsizemake((float)width, (float)height);     uigraphicsbeginimagecontextwithoptions(size, no, 0);     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetfillcolorwithcolor(context, color.cgcolor);     int fonttopposition = (height - expectedtextsize.height) / 2;     cgpoint textpoint = cgpointmake(width + 5, fonttopposition);       // images upside down flip them     //cgaffinetransform flipvertical = cgaffinetransformmake(1, 0, 0, -1, 0, size.height);     //cgcontextconcatctm(context, flipvertical);     cgcontextdrawimage(context, (cgrect){ {0, (height - image.size.height) / 2}, {image.size.width, image.size.height} }, [image cgimage]);     [string drawatpoint:textpoint withattributes:@{nsfontattributename: font}];     uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();     return newimage; } 

image goes blue(default tintcolor).

anyway, if know how segmented control circular(not rounded) segments(buttons), offer solution.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -