2013-11-25 31 views
0

當我打電話的UINavigationBar。外觀。 setBarTintColor不起作用

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

didFinishLaunchingWithOptions

一切工作正常,但下面的代碼給出白色:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:21.0 green:194.0 blue:179.0 alpha:0.5]]; 

我不能理解爲什麼。 NavBar半透明已啓用。

+0

@rmaddy Thx!你是對的! – Max

回答

3
[UIColor colorWithRed:21.0 green:194.0 blue:179.0 alpha:0.5] 

您建立UIColor錯 - 爲每個參數需要創建一個UIColor0.01.0之間的值被接受。爲了得到這些,你的RGB值除以255:

[UIColor colorWithRed:21.0/255.0 green:194.0/255.0 blue:179.0/255.0 alpha:0.5] 
+0

不要鼓勵重複。 – rmaddy

相關問題