ツールバーに Round Rect Button を追加し、xib を介してボタンに画像を配置します。プログラムで画像を変更する必要があります。ツールバーでプログラムでボタンの画像を変更する方法は、グーグルで検索しましたが、まだ解決策がありません。
プログラムでボタン画像を変更したいので、下の画像をご覧ください
みんな、ありがとう
使用しているbutton
IBOutLetを設定してから、プログラムで画像BarButtonItem
を変更します。button
[button setImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
image do exists only on uibutton of custom type.
So create UIButton of type custom.
Now use this button in custom view for UIBarButtonItem
UIBarButtonItem の IBOutlet を作成してみてください。次に、コードで背景画像のプロパティを変更してみてください
画像付きの UIBarButtonItem を作成し、追加します..!?
例:
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithImage: yourImage style: UIBarButtonItemStyleBordered target: nil action: nil];
ボタンの外観が必要ない場合は、次を使用してみてください。
UIBarButtonItem* item = [UIBarButtonItem initWithCustomView: yourImageView];