2011-07-20 5 views
0

触れたときにUIBarButtonを強調表示したい場合は、私に手伝ってください。 iphone sdkでタッチしたときにUIBarButtonをハイライトする方法は?

UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshAction)]; 
self.navigationItem.leftBarButtonItem = leftBarButton; 
[leftBarButton release]; 

はあなた Praveena触れたときのハイライト

+0

Mhあなたのコードを試しましたが、ボタンが強調表示されます。 [ここ](http://img27.imageshack.us/img27/6863/highlight.jpg)を参照してください。 –

答えて

2

UIButtonの動作ですありがとうございました。それはを示していますタッチ時には高輝度に設定すると、はタッチ時に白いフラッシュを示します。だから、あなたはできませんUIBarButtonItemそのように振る舞います。

あなたは、UIButtonを作成をshowsTouchWhenHighlighted有効にし、UIBarButtonItemに追加することができます。

UIButton *btn; 
// Create and configure the UIButton 
btn.showsTouchWhenHighlighted = YES; 
UIBarButtonItem *barBtn = [UIBarButtonItem alloc] initWithCustomView:btn]; 
// Configure and add the UIBarButtonItem 
0

この、

アップルのドキュメント

UIBarButtonItemStylePlain 
Glows when tapped. The default item style. 
Available in iOS 2.0 and later. 
Declared in UIBarButtonItem.h 

それはあなたを助けてを参照してください。