2012-02-04 5 views
1

次のコードを使用してUIBarButtonItemの色合いを設定しようとしていますが、黒いボタンが表示されます。カスタムイメージを使用する必要はありませんが、これを実現する方法はありますか?明瞭な(反転)UIBarButttonItemを作成するIOS 5

[[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]: 

答えて

2

私はこれをしなかったし、UIBarButtonItemsはまだのように黒いて来ているようだボタン

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
[button setImage:buttonImage forState:UIControlStateNormal]; 

//set the frame of the button to the size of the image (see note below) 
button.frame = CGRectMake(0, 0, 24, 24); 
button.backgroundColor=[UIColor clearColor];  
//create a UIBarButtonItem with the button as a custom view 
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button]; 
+0

私はこれを行うことができます、主な問題は私がストーリーボードを介してボタンを追加しているデザイナーです。このようにすると、すべてのボタンをプログラムで追加する必要があります。 – zachzurn

+0

あなたはあなたのcustomBarItemへのアウトレットを作成してから、このcustomBarItem.customView = buttonのようにcustomBarItemのプロパティを設定できます。 –

+0

クリアボタン画像でこれを終了します。 – zachzurn

0

UIToobarまたはUINavigationBarが半透明の場合、バーボタンは自動的に半透明になります。

[[self.navigationController navigationBar] setTranslucent:YES];

私の知る限り、あなたはバーボタンのみ半透明にすることはできません。

+0

とカスタムUIBarButtonItemを作成します。何か案は? – zachzurn

関連する問題