Some the you need to add the buttons just below UINavigationbar, but the UIBarButton on navbar click area interfere with your custom button click area.
I added hitTest:withEvent: code to my custom UINavigationbar subclass..
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
int errorMargin = 5;// space left to decrease the click event area
CGRect smallerFrame = CGRectMake(0 , 0 - errorMargin, self.frame.size.width, self.frame.size.height);
BOOL isTouchAllowed = (CGRectContainsPoint(smallerFrame, point) == 1);
if (isTouchAllowed) {
self.userInteractionEnabled = YES;
} else {
self.userInteractionEnabled = NO;
}
return [super hitTest:point withEvent:event];
}
}
Read More
I added hitTest:withEvent: code to my custom UINavigationbar subclass..
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
int errorMargin = 5;// space left to decrease the click event area
CGRect smallerFrame = CGRectMake(0 , 0 - errorMargin, self.frame.size.width, self.frame.size.height);
BOOL isTouchAllowed = (CGRectContainsPoint(smallerFrame, point) == 1);
if (isTouchAllowed) {
self.userInteractionEnabled = YES;
} else {
self.userInteractionEnabled = NO;
}
return [super hitTest:point withEvent:event];
}
}
Read More
No comments:
Post a Comment