У меня есть панель навигации на viewController, которую я могу включить/отключить. Проблема заключается в том, что я не могу получить шрифт для UIBarButtonItem
s для изменения цвета после того, как изначально загружается представление, хотя стрелка назад изменится.UINavigationBar назад кнопка цвет элемента шрифта не будет установлен
Я отключить UINavigationBar
на myViewController
с помощью следующей строки кода:
self.navigationController.navigationBar.userInteractionEnabled = NO;
Я UIControlState
с сконфигурированной в AppDelegate.m
для UIBarButtonItem
с для включен и выключен, но ничего не происходит шрифту после представление первоначально загружается.
В моей AppDelegate.m
, у меня есть следующий код, чтобы установить шрифт и цвет UINavigationBar
«s:
// UIBarButtonItem styling
NSShadow *shadow = [[NSShadow alloc]init];
shadow.shadowOffset = CGSizeMake(0.0, 1.0);
shadow.shadowColor = [UIColor whiteColor];
// enabled
NSDictionary *enabledTextAttributeDictionary = @{NSForegroundColorAttributeName : [UIColor customCellHyperlinkColor], NSShadowAttributeName: shadow, NSFontAttributeName:[UIFont fontWithName:@"GillSans" size:17.0]};
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:enabledTextAttributeDictionary forState:UIControlStateNormal];
// disabled
NSDictionary *disabledTextAttributeDictionary = @{NSForegroundColorAttributeName : [UIColor lightGrayColor], NSShadowAttributeName: shadow, NSFontAttributeName:[UIFont fontWithName:@"GillSans" size:17.0]};
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:disabledTextAttributeDictionary forState:UIControlStateDisabled];
// UINavigationBarTitle styling
NSDictionary *titleAttributeDictionary = @{NSForegroundColorAttributeName : [UIColor blackColor], NSShadowAttributeName: shadow, NSFontAttributeName:[UIFont fontWithName:@"GillSans" size:19.0]};
[[UINavigationBar appearanceWhenContainedIn:[UINavigationController class], nil]setTitleTextAttributes:titleAttributeDictionary];
Я думал, так как я настроил 2 состояния (UIControlStateNormal
/UIControlStateDisabled
) в AppDelegate.m
, ничто не должно быть кроме включения/выключения navigationBar
. Включение/отключение действительно включает/отключает, но цвет на ярлыке кнопки возврата не изменяется (хотя вначале он был установлен на цвет, который я установил для UIControlStateNormal
в AppDelegate
).
Я попытался установить его вручную, но ярлык на backButtonItem остается синим, а значок слева от него - светло-серый. Что (очевидная вещь) я упускаю, что мешает мне изменить цвет шрифта моей кнопки?
self.navigationController.navigationItem.leftBarButtonItem.tintColor = = [UIColor lightGrayColor]; –
Спасибо. Значки стрелок, но цвет шрифта для ярлыка кнопки «Назад» отсутствует. – Adrian