类似于这种的使用系统的UITabbarController处理
tabbar
1、创建一个UITabBar+Category文件
.h文件
@interfaceUITabBar (Category)
@property (nonatomic, weak) UIButton * btn;
@end
.m文件
#import "UITabBar+Category.h"
@implementation UITabBar (Category)
- (void)setBtn:(UIButton*)btn{
objc_setAssociatedObject(self, @selector(btn), btn, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (UIButton*)btn{
return objc_getAssociatedObject(self, _cmd);
}
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event{
CGPointhitPoint = [self convertPoint:point toView:self.btn];
if([self.btn pointInside:hitPoint withEvent:event]) {
returnself.btn;
}else{
return[super hitTest:point withEvent:event];
}
}
@end
2、在添加+按钮的位置
设置tabbar的btn
以上就👌了。。。。