記錄一下平時(shí)工作遇到的一些小知識(shí).
方法一:自定義視圖
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
titleLabel.backgroundColor = [UIColor grayColor];
titleLabel.font = [UIFont boldSystemFontOfSize:20];
titleLabel.textColor = [UIColor blueColor];
titleLabel.textAlignment = NSTextAlignmentCenter; titleLabel.text = @"導(dǎo)航欄標(biāo)題";
self.navigationItem.titleView = titleLabel;
方法二:在默認(rèn)顯示的標(biāo)題中直接修改文字的大小和顏色坛善。
self.navigationItem.title = @"導(dǎo)航欄標(biāo)題";
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blueColor]}];