我用下面的代码创建了一个自定义后退按钮,但是可点击区域非常大,远远超出了图标本身。有谁知道如何设置可点击区域,或使其与图像大小相同?
谢谢
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;
可点击区域显示为红色。
谢谢!