ナビゲーションコントローラ
3566 ワード
Appledelegate.mでナビゲーションコントローラをルートビューコントローラに設定すると、APPが実行されてナビゲーションコントローラに直接アクセスできます.
ナビゲーションバーのカスタマイズ
**ナビゲーションバーの透過性に関する質問は、記事を参照してください:ナビゲーションバーの透過性に関する質問http://www.jianshu.com/p/96fb78e70740 iOSナビゲーションバー透明、変色アニメーションhttp://www.jianshu.com/p/c4b542913e6f **
コールバックメソッド
//
//
RootViewController *rootVC = [[RootViewController alloc] init];
//rootVC
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:rootVC];
// window
self.window.rootViewController = navi;
ナビゲーションバーのカスタマイズ
//1. , ,
{
// , self.view
// ,
// ,
// 44, 20 , , 64
self.navigationController.navigationBar.translucent = YES;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 64, 100, 50)];
// view.backgroundColor = [UIColor redColor];
//
// [self.view addSubview:view];
//
// self.navigationController.navigationBar.barTintColor = [UIColor purpleColor];
//
// [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"2233"] forBarMetrics:UIBarMetricsDefault];
// . ,
// self.navigationController.navigationBar.hidden = YES;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
// view.backgroundColor = [UIColor whiteColor];
// [self.view addSubview:view];
}
//2. self.navigationItem ,
// self.navigationItem
{
//
// self.title = @" ";
self.navigationItem.title = @" ";
// titleView
UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@" ", @" "]];
// seg.backgroundColor = [UIColor purpleColor];
[seg addTarget:self action:@selector(segmentedControlAction:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = seg;
// self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(leftBarButtonItemAction:)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction:)];
// self.navigationItem.leftBarButtonItems = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(leftBarButtonItemAction:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:[UIImage imageNamed:@"iconfont-daxiao"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction:)];
//
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}
**ナビゲーションバーの透過性に関する質問は、記事を参照してください:ナビゲーションバーの透過性に関する質問http://www.jianshu.com/p/96fb78e70740 iOSナビゲーションバー透明、変色アニメーションhttp://www.jianshu.com/p/c4b542913e6f **
コールバックメソッド
- (void)leftBarButtonItemAction:(UIBarButtonItem *)bar{
self.view.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:arc4random() % 256 / 255.0];
}
- (void)segmentedControlAction:(UISegmentedControl *)seg{
NSLog(@"nihao");
}