以下のコードでカスタムの戻るボタンを作成しましたが、クリック可能な領域は非常に大きく、アイコン自体をはるかに超えています。クリック可能な領域を設定する方法、または画像と同じサイズにする方法を知っている人はいますか?
ありがとう
UIImage *buttonImage = [UIImage imageNamed:@"prefs"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action: @selector(handleBackButton)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
クリック可能な領域は赤で表示されます。
ありがとう!