Thursday, 15 April 2010

ios - UISearchBar set translucent to NO doesn't work -



ios - UISearchBar set translucent to NO doesn't work -

(i know may seem duplicate, i'm telling nil i've found here worked)

i have uitableview search display controller , search bar int it, i'm trying set tintcolor according company colors. it's translucent no matter try.

here sample code:

[self.searchdisplaycontroller.searchbar settranslucent:no]; [self.searchdisplaycontroller.searchbar setbartintcolor:[[conftoolbox sharedinstance] getbartintcolor]];

[[conftoolbox sharedinstance] getbartintcolor] returns dark-ish bluish uicolor .

i've looked around reply nil worked, this accepted answer.

any help great.

cheers,

ayu.

i achieved wanted using this, in case faces same problem:

uigraphicsbeginimagecontextwithoptions(cgsizemake(10,10), yes, 0); cgcontextsetfillcolorwithcolor(uigraphicsgetcurrentcontext(), [[conftoolbox sharedinstance] bartintcolor].cgcolor); cgcontextfillrect(uigraphicsgetcurrentcontext(), cgrectmake(0,0,10,10)); uiimage* coloredimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); [self.searchdisplaycontroller.searchbar setbackgroundimage:coloredimage forbarposition:uibarpositionany barmetrics:uibarmetricsdefault];

you can set sec parameter of cgcontextsetfillcolorwithcolor whatever color want.

from documentation

the default value yes. if search bar has custom background image, default yes if pixel of image has alpha value of less 1.0, , no otherwise.

since image made color alpha value of 1, translucent effect off stated.

ios uitableview uisearchbar

No comments:

Post a Comment