// 生成例 UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"ぼたん" // ボタンタイトル名を指定 style:<UIBarButtonItemStyleスタイル> // スタイルを指定(※下記表参照) target:self // デリゲートのターゲットを指定 action:@selector(hoge)// ボタンが押されたときに呼ばれるメソッドを指定 ]; // システムで用意されている画像を使った生成例 UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:<UIBarButtonSystemItemスタイル> // スタイルを指定 target:self // デリゲートのターゲットを指定 action:@selector(hoge) // ボタンが押されたときに呼ばれるメソッドを指定 ]; // システムで用意されている画像を使った生成例 UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:<UIBarButtonSystemItemスタイル> // スタイルを指定 target:self // デリゲートのターゲットを指定 action:@selector(hoge) // ボタンが押されたときに呼ばれるメソッドを指定 ]; |
action
style
target
width
customView
possibleTitles
initWithBarButtonSystemItem:target:action:
例)UIBarButtonItem *btnitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hoge)];
initWithCustomView:
例)UIBarButtonItem *btnitem = [[UIBarButtonItem alloc] initWithCustomView:customView];
initWithImage:style:target:action:
例)UIBarButtonItem *btnitem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonSystemItemDone target:self action:@selector(hoge)];
initWithTitle:style:target:action:
例)UIBarButtonItem *btnitem = [[UIBarButtonItem alloc] initWithTitle:@"たいとる" style:UIBarButtonSystemItemDone target:self action:@selector(hoge)];