ios - UIBarButtonItem tintColor stopped working -
for reason can't use uinavigationbar on view , use uitoolbar instead. using dummy left button clear tintcolor , title button black tintcolor center title , hide dummy left bar button, it's not working anymore , both dummy left button , title button either main tintcolor or if disable them, become gray.
how can make them ideally disabled buttons , set proper tintcolor (clear , black)?
- (void)addtoolbar { cgfloat barheight = 44.0; uitoolbar *toolbar = [[uitoolbar alloc] initwithframe:cgrectmake(self.view.bounds.origin.x, self.view.bounds.size.width - barheight, self.view.bounds.size.height, barheight)]; uibarbuttonitem *flexiblespacebuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; // done button on right uibarbuttonitem *donebuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target:self action:@selector(done)]; // dummy button on left have centered title uibarbuttonitem *dummybuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target:nil action:nil]; dummybuttonitem.enabled = no; dummybuttonitem.tintcolor = [uicolor clearcolor]; // title button uibarbuttonitem *titlebuttonitem = [[uibarbuttonitem alloc] initwithtitle:@"title text here" style:uibarbuttonitemstyleplain target:nil action:nil]; titlebuttonitem.enabled = no; titlebuttonitem.tintcolor = [uicolor blackcolor]; // set toolbar items toolbar.items = @[dummybuttonitem,flexiblespacebuttonitem, titlebuttonitem, flexiblespacebuttonitem,donebuttonitem]; [self.view addsubview:toolbar]; }
when specify tint view, tint automatically propagated subviews in view’s hierarchy. because uiwindow inherits uiview, can specify tint color entire app setting window’s tint property using code this:
under application:didfinishlaunchingwithoptions:
window.tintcolor = [uicolor purplecolor];
source - ios transitions . check out under using tint color section
Comments
Post a Comment