2014-07-10 2 views
1

내 앱에서 UIAppearance를 사용하여 탐색 바의 색상을 변경하려고합니다.UIAppearence는 iOS의 시스템 색상에서만 작동합니까?

하지만 시스템 색상을 사용하는 경우에만 작동합니다

UINavigationBar *navigationBarAppearance = [UINavigationBar appearance]; 

    [navigationBarAppearance setBarTintColor:[[UIColor alloc] initWithRed:220.0f green:47.0f blue:40.0f alpha:100.0f]]; // does not work 

    [navigationBarAppearance setBarTintColor:[UIColor colorWithRed:220.0f green:47.0f blue:40.0f alpha:100.0f]]; // does not work 

    [navigationBarAppearance setBarTintColor:[UIColor redColor]]; // works 

어떤 제안이?

+2

'UIColor'문서를 읽었어야합니다. 사용중인 메서드는 0.0과 1.0 사이의 값을 받아들이지 만 0.0과 255.0은 허용하지 않습니다. – duci9y

+2

@ duci9y 네가 맞아. 불행히도 당신은 대답 대신에 답글로 게시물을 올렸으므로 나는 Fry의 대답을 받아 들여야합니다. – mrd

답변

0

방법

colorWithRed:green:blue:alpha: 

처럼, 사용자 정의 색상 방법으로 잘못하고 0.01.0 사이에 네 개의 값을 받아 들일 생각합니다. 따라서 0.0에서 255.0까지의 구성 요소가있는 경우 255.0f으로 나누어 정규화해야합니다.

[UIColor alloc] initWithRed:220.0f/255.0f green:47.0f/255.0f blue:40.0f/255.0f alpha:100.0f/255.0f] 
1

난 당신이이

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:127.0f/255.0f green:127.0f/255.0f blue:127.0f/255.0f alpha:1.0f]]; 
관련 문제