まず、rightBarButtonItemをナビゲーションバーに追加し、アルファを0.0に設定する必要があります
彼らはこれを試してみます
[UIView animateWithDuration:0.3f
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{
self.navigationItem.rightBarButtonItem.customView.alpha = 1.0f;
}
completion:^(BOOL finished) {
}];
アップデート
あなたのコードで
if (blaa blaa) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"search" forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView: btn] autorelease];
self.navigationItem.rightBarButtonItem.customView.alpha = 0.0f;
}
次に、上記のコードを使用できます
アップデート
申し訳ありませんが、コードを確認しました。UIViewControlerはbarButtonItemプロパティをリセットするため、ビューを表示する前にagianを設定する必要があります。
- (void)viewDidAppear:(BOOL)animated
{
self.navigationItem.rightBarButtonItem.customView.alpha = 0.0f;
}
次にボタンがタップされたとき
- (void) buttonTap:(UIButton*)btn
{
[UIView animateWithDuration:1.0f
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{
self.navigationItem.rightBarButtonItem.customView.alpha = 1.0f;
}
completion:^(BOOL finished) {
}];
}
それはうまくいくはずです!