iOS版でUINavigationBarを色付け
-
11-09-2019 - |
質問
私はオレンジ色の私のナビゲーションバーを色付け
navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.88 green:0.52 blue:0.27 alpha:1];
すべてがうまく動作、すべてのボタンはバーとしてオレンジのようですが、ICはカスタム右項目メニューにcamesとき、それは青を示しています。 これはスクリーンショットです: http://img146.imageshack.us/img146/5605/schermata20091202a14565 .PNGする
これは、右ボタンのコードです:
UIView *container = [[UIView alloc] init];
UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addGadget:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"less.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setEditing:)];
[buttons addObject:bi];
[bi release];
[tools setItems:buttons animated:NO];
[buttons release];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
オレンジ色のようにすべてのものを作るには?
解決
あなたはtintColor
のそれと同じになるようにUIToolbar
オブジェクトのUINavigationBar
を設定する必要があります。
UIToolbar
はUINavigationBar
と同じではない、背景グラデーション/色が少し異なることに注意してください。 +[UIColor clearColor]
するUIToolbarのbackgroundColorを設定してみてください。
また、UIView
はUIToolbar
のサブクラスであるため、あなたはおそらく、コンテナUIView
を必要としないので、あなたはただ、それ自体でのCustomViewとして使用することができます。
所属していません StackOverflow