我試圖在UINavigationController的標題內添加一個UISegmentedControl。但是,格式看起來像這樣(即醜陋)。UINavigationControl裏面的UINavigationBar標題看起來沒有格式化
當我希望它看起來像這樣(漂亮:)。誰能幫忙?
我已經紅工匠here閱讀通俗的例子。但是我並沒有把它看作我的第一個視圖(就像Red Artisan一樣),所以我將很多代碼從App Delegate中移出。在應用程序委託中,我將此屏幕設置爲UINavigationController,其rootView是UIViewController。
GenInfoViewController *genInfoController = [[GenInfoViewController alloc] initWithNibName:@"GenInfoViewController" bundle:nil];
UINavigationController *genInfoNavController = [[UINavigationController alloc] initWithRootViewController:genInfoController];
然後在GenInfoViewController.m的viewDidLoad中我做到以下幾點:
self.segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Info",@"Map"]];
self.navigationItem.titleView = self.segmentedControl;
'segmentedControlStyle'棄用iOS7 +。 – Zorayr 2015-08-04 05:27:48