0

私のナビゲーション バーには、2 つの右ボタン バー項目があります。1 つはカスタム ボタンで、もう 1 つは情報ライト ボタン タイプを使用します。どちらもうまく機能しますが、カスタムボタンに触れたときに情報ボタンと同じようにデフォルトの輝きを持たせたいと思います。これは可能ですか?

// Default info light btn
UIButton *infoBtn = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoBtnItem = [[UIBarButtonItem alloc]initWithCustomView:infoBtn];

// Custom Btn
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setFrame:CGRectMake(0, 0, btnImage.size.width, btnImage.size.height)];
[customButton setBackgroundImage:btnImage forState:UIControlStateNormal];
[customButton addTarget:self action:@selector(rightDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customButtonItem = [[UIBarButtonItem alloc] initWithCustomView:wlButton];

NSArray *rightBtns = @[customButtonItem, infoBtnItem];
[navItem setRightBarButtonItems:rightBtns animated:YES];
4

1 に答える 1

3

次のようなコードをもう 1 行追加するだけです。

customButton.showsTouchWhenHighlighted = TRUE;

この後、コードは次のようなものを出力します:-

ここに画像の説明を入力

于 2013-08-02T20:57:23.137 に答える