Reputation: 1552
I have a custom UIToolbar
in my UINavigationController
, with a custom background image.
The image is half transparent on the right. The problem that I'm having is that some views have buttons on the bottom right and the bottom part of those buttons cannot be tapped because the toolbar blocks it.
I cannot set userInteractionEnabled = NO
on the UIToolBar
, because the bar contains UIBarButtonItem
s which need to remain interactive.
Is there a way to make the bar ignore tap inputs (but not the UIBarButtonItem
s)?
Upvotes: 0
Views: 637
Reputation: 7416
You can set userInteractionEnabled = YES
on the toolbar, but override hitTest:point
as described in How to get touches when parent view has userInteractionEnabled set to NO in iOS. This makes it ignore any touches on itself, but accept any touches on any subviews (UIBarButtonItem
s in your case):
- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == self) {
return nil;
} else {
return hitView;
}
}
Note that this would require you to subclass UIToolbar
.
Upvotes: 1