ios - Change UIButton BG color on highlighted, but preserve layer corner radius? -


i’m changing background colour of uibutton via category method, using 1px 1px image:

- (void)setbackgroundcolor:(uicolor *)backgroundcolor forstate:(uicontrolstate)state {     uigraphicsbeginimagecontextwithoptions(cgsizemake(1, 1), no, 0);     [backgroundcolor setfill];     cgcontextfillrect(uigraphicsgetcurrentcontext(), cgrectmake(0, 0, 1, 1));     uiimage *backgroundimage = uigraphicsgetimagefromcurrentimagecontext();     [self setbackgroundimage:backgroundimage forstate:state];     uigraphicsendimagecontext(); } 

however, overrides setting of .layer.cornerradius. need button rounded corners, 1 background colour can change on highlighted.

any way around this? corner radius needs dynamic.

so, had ensure button.layer.maskstobounds turned on. problem solved, no subclassing required.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -