objective c - iOS 7 UIBarButtonItem font changes when tapped -


i'm attempting change uibarbuttonitem font. looks when viewcontrollers load. if tap on bar button, or swipe right if move previous viewcontroller (but pull current one), font changes system font. here's i'm setting in appdelegate:

nsdictionary* barbuttonitemattributes = @{nsfontattributename: [uifont fontwithname:@"sourcesanspro-light" size:20.0f]}; [[uibarbuttonitem appearance] settitletextattributes: barbuttonitemattributes forstate:uicontrolstatenormal]; [[uibarbuttonitem appearance] settitletextattributes: barbuttonitemattributes forstate:uicontrolstatehighlighted]; [[uibarbuttonitem appearance] settitletextattributes: barbuttonitemattributes forstate:uicontrolstateselected]; [[uibarbuttonitem appearance] settitletextattributes: barbuttonitemattributes forstate:uicontrolstatedisabled]; 

and here's example of viewwillappear:

- (void) viewwillappear:(bool)animated {     self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithtitle:@"done" style:uibarbuttonitemstyleplain target:self action:@selector(donebuttonpressed)];     self.navigationitem.rightbarbuttonitem.tintcolor = [uicolor colorwithred:141.0/255.0 green:209.0/255.0 blue:205.0/255.0 alpha:1.0]; } 

am somehow changing font back, or misusing appearance proxy?

the problem tintcolor setting conflicts title text attributes. comment out line , well.

if going use title text attributes, incorporate text color attributes:

nsdictionary* barbuttonitemattributes = @{nsfontattributename:       [uifont fontwithname:@"georgia" size:20.0f],   nsforegroundcolorattributename:       [uicolor colorwithred:141.0/255.0 green:209.0/255.0 blue:205.0/255.0 alpha:1.0]    }; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -