描述
iOS自定义TabBar中间凸起样式
iOS解决超出frame区域无法点击问题
自定义中间(任意位置)凹凸样式的TabBar
- 定制样式很简单,主要是处理超出区域无法点击的问题
- 示例代码如下:
/**
使UITabBar上面的所有可视控件都可接受touch事件,即使控件超出frame区域
*/
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
if (CGRectContainsPoint(self.bounds, point)){
return [super hitTest:point withEvent:event];
}else{
UIView *targetView = [super hitTest:point withEvent:event];
if (self.isHidden) {
return targetView;
}
for (UIView *view in self.subviews) {
if (view.isHidden == NO) {
CGPoint tempPoint = [view convertPoint:point fromView:self];
if (CGRectContainsPoint(view.bounds, tempPoint)){
targetView = view;
break;
}
}
}
return targetView;
}
}
网友评论