2014-06-24 1 views
1

상태 표시 줄의 배경색을 변경하고 해당 배경색이 탐색 모음 배경색, 즉 어두운 회색 색상과 같아야합니다. 내 문제는 상태 표시 줄과 내 아래 코드를 사용하여 탐색 모음에 동일한 색상을 부여한 후, 나는 다른 색상을 받고있다. 이미 UIViewControllerBasedStatusBarAppearance를 NO로 설정했습니다. 제발 내가 잘못하고있는 곳을 제안 해주세요, 나는 당신의 참고를 위해 이미지 아래에 붙어있다. UIStatusBarStyleLightContent[UIColor darkGrayColor]과 같은 색이 아니기 때문에왜 iOS에서 상태 표시 줄과 탐색 모음 배경색이 다른지

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    //For changing status bar background color 

    self.window.backgroundColor = [UIColor darkGrayColor]; 

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade]; 

    //For changing navigation bar background color 

    [[UINavigationBar appearance] setBackgroundColor:[UIColor darkGrayColor]]; 
    [[UINavigationBar appearance] setTintColor:[UIColor darkGrayColor]]; 

enter image description here

+0

'UIStatusBarStyleLightContent'는 (는)'[UIColor darkGrayColor] '와 (과) 동일합니까? –

+0

sry .. 참조 용 스크린 샷을 첨부하고 있습니다. –

답변

0

서로 다른 색상을 가지고있는 이유는 : didFinishLaunchingWithOptions -

enter image description here

여기 앱 위임의 내 코드입니다. 이 상태 표시 줄과 같은 방법 후 탐색 줄의 색상 조정이 괜찮 경우


, 당신은 상태 표시 줄의 색상을 설정할 수 있습니다

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 

상태 표시 줄의 RGB 값을 알아보십시오. 예를 들어 DigitalColor Meter를 사용하면 R : 28, G : 28, B : 28이 있다고 말합니다. 당신은 NO에 투명도를 설정해야 할 수 있습니다

[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:28/255.0 green:28/255.0 blue:28/255.0 alpha:1.0f]]; 

:

그럼 당신은 뭔가를 할 수 있습니다.

당신이 특정 화면에 원하는 경우 viewDidLoad 방법이를 추가 할 수 있습니다

이 이
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:28/255.0 green:28/255.0 blue:28/255.0 alpha:1.0f]]; 
+0

고맙습니다 @로드 졸트, 제 코드가 변경되었습니다. 이제 나는 두 가지 모두에 대해 비슷한 bg 색상을 얻고 있습니다. UIColor colorWithRed : (51/255.0) green : (51/255.0) blue : (51/255.0) alpha : 1.0]]와 같이 bg 색상을 설정해야하는지 알려주십시오. 그러면 UINavigationBar의 bg 및 tint 색상이 무엇입니까? –

+0

그것은 "상태 표시 줄에 따라 탐색 막대 색상을 설정하는 것이 좋으면"라고 말한 것입니다. 상태 표시 줄에는 미리 설정된 색상이 몇 가지 있습니다. 그 이후에는 탐색 막대를 조정해야하며 그 반대는 아닙니다. –

+0

okey..now 내 상태 표시 줄과 탐색 표시 줄에 모두 동일한 배경색이 나타나지만 상태 표시 줄과 탐색 모음 사이에 작은 검은 색 분리 선이 하나 생기는 이유는 모르겠다. pls 내 업데이트 된 질문을 확인 (나는 스크린 샷 첨부). pls 나에게 건의함. 감사합니다. –

0

먼저 변경하여 VC의 viewDidLoad에 방법의 상태 표시 스타일

self.navigationController.navigationBar.barStyle = UIBarStyleBlack; 

그리고 변경 VC의 viewDidLoad 메서드에서 원하는 색상으로 BarTintColor을 입력하십시오.

[self.navigationController.navigationBar setBarTintColor:[UIColor blackColor]]; 
0

AppDelegate의 'didFinishLaunchingWithOptions :'에 다음을 추가하면 제대로 작동합니다.

[[UINavigationBar appearance] setBarTintColor:[UIColor darkGrayColor]];