[英]Change title of a Navigation Bar dragged in storyboard
我想更改我從調色板拖到情節提要中的導航欄標題的字體和顏色(不是使用nag控制器+推送功能自動創建)。 我已經嘗試過
self.navigationController.topViewController.title = @"title";
self.title = @"title";
self.navigationItem.title = @"title";
但它們都不起作用。 沒有標題顯示,因此我什至沒有嘗試任何字體或顏色的更改。 我該如何解決?
確保導航欄是某些navigationController的一部分。
嘗試這個 :
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar setBackgroundImage: [UIImage imageNamed:@"NavBarColor"] forBarMetrics: UIBarMetricsDefault];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
self.title = @"Title here!";
要不然 :
UILabel* titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 170.0f, 44.0f)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.textColor = [UIColor colorWithRed: 0.922f green: 0.925f blue: 0.973f alpha: 1.0f];
titleLabel.font = [Utils helveticaBoldFontOfSize: 19.333f];
titleLabel.text = NSLocalizedString(@"Title Here", nil);
self.navigationItem.titleView = titleLabel;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.