微信下方的TabBar(MMTabBarController )有新消息会弹出Badge数字,我想修改这个数字。在cycript里可以直接通过choose获取到MMTabBarController 实例,然后调用实例的方法
- (void)setTabBarBadgeValue:(int)arg1 forIndex:(int)arg2;
但是,在THEOS里应该如何实现呢?
下面是MMTabBarController的头文件:
#import “UITabBarController.h”
@class MMDelegateProxy, NSMutableArray, UITapGestureRecognizer;
@interface MMTabBarController : UITabBarController
{
unsigned long _viewControllersCount;
NSMutableArray *_tabBarBtns;
NSMutableArray *_badgeViews;
UITapGestureRecognizer *_doubleTapGesture;
BOOL _hasDoubleTapGesture;
}
- (void)willAnimateRotationToInterfaceOrientation:(int)arg1 duration:(double)arg2;
- (unsigned int)supportedInterfaceOrientations;
- (BOOL)shouldAutorotateToInterfaceOrientation:(int)arg1;
- (void)setTabBarBadgeImage:(id)arg1 forIndex:(unsigned int)arg2;
- (void)setTabBarBadgeString:(id)arg1 forIndex:(int)arg2;
- (void)setTabBarBadgeValue:(int)arg1 forIndex:(int)arg2;
- (id)getViewControllerAtIndex:(unsigned long)arg1;
在cycript里可以通过
cy#var tabbar = choose(MMTabBarController)[0]
#"<MMTabBarController: 0x7dcd8d0>"
获得,也可以一步一步这样获得:
cy#var tabbar = [UIApplication sharedApplication].keyWindow.rootViewController
#"<MMTabBarController: 0x7dcd8d0>"
调用方法:cy#[tabbar setTabBarBadgeValue:5 forIndex:0]