|
16 | 16 | #import "UINavigationBar+Transition.h" |
17 | 17 | #import "QMUICore.h" |
18 | 18 | #import "UINavigationBar+QMUI.h" |
| 19 | +#import "UINavigationBar+QMUIBarProtocol.h" |
19 | 20 | #import "QMUIWeakObjectContainer.h" |
20 | 21 | #import "UIImage+QMUI.h" |
21 | 22 |
|
@@ -53,17 +54,53 @@ + (void)load { |
53 | 54 | } |
54 | 55 | }); |
55 | 56 |
|
56 | | - ExtendImplementationOfVoidMethodWithTwoArguments([UINavigationBar class], @selector(setBackgroundImage:forBarMetrics:), UIImage *, UIBarMetrics, ^(UINavigationBar *selfObject, UIImage *backgroundImage, UIBarMetrics barMetrics) { |
57 | | - if (selfObject.qmuinb_copyStylesToBar) { |
58 | | - [selfObject.qmuinb_copyStylesToBar setBackgroundImage:backgroundImage forBarMetrics:barMetrics]; |
59 | | - } |
| 57 | + OverrideImplementation([UINavigationBar class], @selector(setBackgroundImage:forBarPosition:barMetrics:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) { |
| 58 | + return ^(UINavigationBar *selfObject, UIImage *image, UIBarPosition barPosition, UIBarMetrics barMetrics) { |
| 59 | + |
| 60 | + // call super |
| 61 | + void (*originSelectorIMP)(id, SEL, UIImage *, UIBarPosition, UIBarMetrics); |
| 62 | + originSelectorIMP = (void (*)(id, SEL, UIImage *, UIBarPosition, UIBarMetrics))originalIMPProvider(); |
| 63 | + originSelectorIMP(selfObject, originCMD, image, barPosition, barMetrics); |
| 64 | + |
| 65 | + if (selfObject.qmuinb_copyStylesToBar) { |
| 66 | + [selfObject.qmuinb_copyStylesToBar setBackgroundImage:image forBarPosition:barPosition barMetrics:barMetrics]; |
| 67 | + } |
| 68 | + }; |
60 | 69 | }); |
61 | 70 |
|
62 | 71 | ExtendImplementationOfVoidMethodWithSingleArgument([UINavigationBar class], @selector(setShadowImage:), UIImage *, ^(UINavigationBar *selfObject, UIImage *firstArgv) { |
63 | 72 | if (selfObject.qmuinb_copyStylesToBar) { |
64 | 73 | selfObject.qmuinb_copyStylesToBar.shadowImage = firstArgv; |
65 | 74 | } |
66 | 75 | }); |
| 76 | + |
| 77 | + OverrideImplementation([UINavigationBar class], @selector(setQmui_effect:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) { |
| 78 | + return ^(UINavigationBar *selfObject, UIBlurEffect *firstArgv) { |
| 79 | + |
| 80 | + // call super |
| 81 | + void (*originSelectorIMP)(id, SEL, UIBlurEffect *); |
| 82 | + originSelectorIMP = (void (*)(id, SEL, UIBlurEffect *))originalIMPProvider(); |
| 83 | + originSelectorIMP(selfObject, originCMD, firstArgv); |
| 84 | + |
| 85 | + if (selfObject.qmuinb_copyStylesToBar) { |
| 86 | + selfObject.qmuinb_copyStylesToBar.qmui_effect = firstArgv; |
| 87 | + } |
| 88 | + }; |
| 89 | + }); |
| 90 | + |
| 91 | + OverrideImplementation([UINavigationBar class], @selector(setQmui_effectForegroundColor:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) { |
| 92 | + return ^(UINavigationBar *selfObject, UIColor *firstArgv) { |
| 93 | + |
| 94 | + // call super |
| 95 | + void (*originSelectorIMP)(id, SEL, UIColor *); |
| 96 | + originSelectorIMP = (void (*)(id, SEL, UIColor *))originalIMPProvider(); |
| 97 | + originSelectorIMP(selfObject, originCMD, firstArgv); |
| 98 | + |
| 99 | + if (selfObject.qmuinb_copyStylesToBar) { |
| 100 | + selfObject.qmuinb_copyStylesToBar.qmui_effectForegroundColor = firstArgv; |
| 101 | + } |
| 102 | + }; |
| 103 | + }); |
67 | 104 | }); |
68 | 105 | } |
69 | 106 |
|
@@ -105,9 +142,13 @@ - (void)setQmuinb_copyStylesToBar:(UINavigationBar *)copyStylesToBar { |
105 | 142 | if (![copyStylesToBar.barTintColor isEqual:self.barTintColor]) { |
106 | 143 | copyStylesToBar.barTintColor = self.barTintColor; |
107 | 144 | } |
| 145 | + |
108 | 146 | #ifdef IOS15_SDK_ALLOWED |
109 | 147 | } |
110 | 148 | #endif |
| 149 | + |
| 150 | + copyStylesToBar.qmui_effect = self.qmui_effect; |
| 151 | + copyStylesToBar.qmui_effectForegroundColor = self.qmui_effectForegroundColor; |
111 | 152 | } |
112 | 153 |
|
113 | 154 | - (UINavigationBar *)qmuinb_copyStylesToBar { |
|
0 commit comments