我试图在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