Open ghost opened 8 years ago
An easy way to solve it and simplify the method:
From: `- (void)lt_setElementsAlpha:(CGFloat)alpha { [[self valueForKey:@"_leftViews"] enumerateObjectsUsingBlock:^(UIView view, NSUInteger i, BOOL stop) { view.alpha = alpha; }];
[[self valueForKey:@"_rightViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
view.alpha = alpha;
}];
UIView *titleView = [self valueForKey:@"_titleView"];
titleView.alpha = alpha;
// when viewController first load, the titleView maybe nil [[self subviews] enumerateObjectsUsingBlock:^(UIView obj, NSUInteger idx, BOOL stop) { if ([obj isKindOfClass:NSClassFromString(@"UINavigationItemView")]) { obj.alpha = alpha; *stop = YES; } }]; }`
To: `- (void)lt_setElementsAlpha:(CGFloat)alpha { self.tintColor = [self.tintColor colorWithAlphaComponent:alpha];
UIView *titleView = [self valueForKey:@"_titleView"];
titleView.alpha = alpha;
// when viewController first load, the titleView maybe nil [[self subviews] enumerateObjectsUsingBlock:^(UIView obj, NSUInteger idx, BOOL stop) { if ([obj isKindOfClass:NSClassFromString(@"UINavigationItemView")]) { obj.alpha = alpha; *stop = YES; } }]; }`
If the navigation bar have a back button item it didn't change alpha value and is always displayed in statusbar