文章40 | 阅读 18244 | 点赞0
s.resources = ['Classes/**/*.{xib,storyboard,Bundle,png,gif,jpg,jpeg,txt}', 'Resource/**/*']
s.resource = 'xx/xxx.bundle'
s.resource_bundles = { 'xxx' => ['/Classes/**/*.{xib,storyboard,Bundle,png,gif,jpg,jpeg,txt}', 'Resource/**/*'] }
动态 pod:adhoc 58.9M,pub 130.6M
静态 pod:adhoc 58.3M,pub 131.6M
Total pre-main time: 819.46 milliseconds (100.0%)
dylib loading time: 542.43 milliseconds (66.1%)
rebase/binding time: 35.86 milliseconds (4.3%)
ObjC setup time: 57.79 milliseconds (7.0%)
initializer time: 183.27 milliseconds (22.3%)
slowest intializers :
libSystem.B.dylib : 10.33 milliseconds (1.2%)
libMainThreadChecker.dylib : 28.76 milliseconds (3.5%)
AFNetworking : 83.46 milliseconds (10.1%)
Realm : 27.37 milliseconds (3.3%)
CYKJBasicModule : 17.54 milliseconds (2.1%)
Total pre-main time: 591.00 milliseconds (100.0%)
dylib loading time: 447.06 milliseconds (75.6%)
rebase/binding time: 30.51 milliseconds (5.1%)
ObjC setup time: 20.26 milliseconds (3.4%)
initializer time: 93.04 milliseconds (15.7%)
slowest intializers :
libSystem.B.dylib : 7.67 milliseconds (1.2%)
libMainThreadChecker.dylib : 25.41 milliseconds (4.3%)
Realm : 21.13 milliseconds (3.5%)
CYKJMain : 57.87 milliseconds (9.7%)
+ (NSBundle *)bundleWithClassName:(Class)cls moduleName:(NSString*)module {
if (module == nil) {
return [NSBundle mainBundle];
}
NSBundle * bundle = [NSBundle bundleForClass:cls];
NSURL * bundleURL = [bundle URLForResource:module withExtension:@"bundle"];
if (bundleURL == nil) {
__block UINavigationController* nav;
[[UIApplication sharedApplication].windows enumerateObjectsUsingBlock:^(__kindof UIWindow * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIViewController * windowVC = obj.rootViewController;
if ([windowVC isKindOfClass:[UINavigationController class]]) {
nav = (UINavigationController *)windowVC;
*stop = YES;
}
}];
if (nav != nil) {
Class callerCls = [nav.viewControllers.firstObject class];
bundle = [NSBundle bundleForClass:callerCls];
bundleURL = [bundle URLForResource:module withExtension:@"bundle"];
}
if (bundleURL == nil) {
return [NSBundle mainBundle];
}
}
return [NSBundle bundleWithURL:bundleURL];
}
+ (void)load {
_imageViewImageArray = [NSMutableArray arrayWithCapacity:2];
propKey = [CYKJXUtil stringByReversed:@"emaNecruoseRIU"];
btnKey = [CYKJXUtil stringByReversed:@"tnetnoClufetatSnottuBIU"];
// hook UINibDecoder - decodeObjectForKey:
NSString* clsName = [NSString stringWithFormat:@"redoce%@biNIU", @"D"];
clsName = [CYKJXUtil stringByReversed:clsName];
[HookTool exchangeInstanceMethod:NSClassFromString(clsName)
originalSEL:@selector(decodeObjectForKey:)
swizzledSEL:@selector(swizzle_decodeObjectForKey:)];
// hook UIImageView - initWithCoder:
[HookTool exchangeInstanceMethod:UIImageView.class
originalSEL:@selector(initWithCoder:)
swizzledSEL:@selector(swizzle_imageView_initWithCoder:)];
// hook UIButton - initWithCoder:
[HookTool exchangeInstanceMethod:UIButton.class
originalSEL:@selector(initWithCoder:)
swizzledSEL:@selector(swizzle_button_initWithCoder:)];
}
- (id)swizzle_decodeObjectForKey:(NSString *)key {
Method originalMethod = class_getInstanceMethod([HookTool class], @selector(swizzle_decodeObjectForKey:));
IMP function = method_getImplementation(originalMethod);
id (*functionPoint)(id, SEL, id) = (id (*)(id, SEL, id)) function;
id value = functionPoint(self, _cmd, key);
// 保存图片名称
if ([key isEqualToString:propKey]) {
[_imageViewImageArray addObject:value];
}
// 保存 button 状态数据
if ([key isEqualToString:btnKey]) {
if ([value isKindOfClass:[NSDictionary class]]) {
_buttonImageDictionary = value;
}
}
return value;
}
#pragma mark - UIImageView
- (id)swizzle_imageView_initWithCoder:(NSCoder *)aDecoder {
// 执行顺序:initWithCoder -》DecoderWithKey -》setImage:,所以每次给 imageView 设置图片时,需要将之前的置空。
// tabbarItem 的图片设置不会执行 initWithCoder,如果不置空,会导致 imageView 设置成和 tabbarItem 一样的图片。
[_imageViewImageArray removeAllObjects];
UIImageView * instance = (UIImageView *)[self swizzle_imageView_initWithCoder:aDecoder];
// 设置 image
if (_imageViewImageArray.count > 0) {
UIImage * normalImage = [HookTool imageAfterSearch:_imageViewImageArray[0]];
if (normalImage) {
instance.image = normalImage;
}
}
// 设置 highlightedImage
if (_imageViewImageArray.count > 1) {
UIImage * highlightedImage = [HookTool imageAfterSearch:_imageViewImageArray[1]];
if (highlightedImage) {
instance.highlightedImage = highlightedImage;
}
}
return instance;
}
#pragma mark - UIButton
- (id)swizzle_button_initWithCoder:(NSCoder *)aDecoder {
// 执行顺序:initWithCoder -》DecoderWithKey -》setImage:,所以每次给 button 设置图片时,需要将之前的置空。
// tabbarItem 的图片设置不会执行 initWithCoder,如果不置空,会导致 button 设置成和 tabbarItem 一样的图片。
[_imageViewImageArray removeAllObjects];
_buttonImageDictionary = nil;
UIButton * instance = (UIButton *)[self swizzle_button_initWithCoder:aDecoder];
@autoreleasepool {
[_buttonImageDictionary enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key,
id _Nonnull obj,
BOOL * _Nonnull stop) {
if (_imageViewImageArray.count == 0) {
*stop = YES;
}
else {
switch ([key integerValue]) {
case ButtonImageOrder_Normal:
[HookTool setImageForButton:instance object:obj state:UIControlStateNormal];
break;
case ButtonImageOrder_Highlighted:
[HookTool setImageForButton:instance object:obj state:UIControlStateHighlighted];
break;
case ButtonImageOrder_Selected:
[HookTool setImageForButton:instance object:obj state:UIControlStateSelected];
break;
case ButtonImageOrder_Disabled:
[HookTool setImageForButton:instance object:obj state:UIControlStateDisabled];
break;
}
}
}];
}
return instance;
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Forever_wj/article/details/120853770
内容来源于网络,如有侵权,请联系作者删除!