我正在创建一个 UIBarButtonItem 并将其添加到我的导航栏中,如下所示:
(void)viewDidLoad {
...
// Add the refresh button to the navigation bar
UIButton *refreshButton = [UIButton buttonWithType:UIButtonTypeCustom];
[refreshButton setFrame:CGRectMake(0,0,30,30)];
[refreshButton setImage:[UIImage imageNamed:@"G_refresh_icon.png"] forState:UIControlStateNormal];
[refreshButton addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *refreshBarButton = [[[UIBarButtonItem alloc] initWithCustomView:refreshButton] autorelease];
self.navigationItem.leftBarButtonItem = refreshBarButton;
}
运行时它看起来是正确的,但是我可以通过在 x = 0 到大约 100 之间的任意位置点击导航栏来选择条形按钮项。如何将可选区域调整为 30 像素的宽度?