黑名单无效
dong136279559 opened this issue · 13 comments
作者你好,我这边也发现该库和TZImagePickerController一起使用时有这个问题,我做了如下改动修复了黑名单失效问题,供参考哈:
1、在readme的基础之上,把TZImagePickerController也加入到黑名单中
2、在WRNavigationBar的updateNavigationBarWithFromVC:toVC:progress:
方法最前面,加上如下判断:
- (void)updateNavigationBarWithFromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC progress:(CGFloat)progress {
if (![WRNavigationBar needUpdateNavigationBar:toVC]) {
return;
}
// 源码中非黑名单的正常处理
}
这两处改动解决了我的问题,框架的其它特性没做验证,供大家参考~
needUpdateNavigationBar 没有这个方法哈
@xhjss 有的,难道是你的版本比较低?
@ banchichen 设置完还是不行 还有needUpdateNavigationBar为什么跟你看的实现不一样
- (BOOL)needUpdateNavigationBar:(UIViewController *)vc {
NSString *vcStr = NSStringFromClass(vc.class);
if ([self isLocalUsed]) {
return [[self whitelist] containsObject:vcStr]; // 当白名单里 有 表示需要更新
} else {
return ![[self blacklist] containsObject:vcStr];// 当黑名单里 没有 表示需要更新
}
}
@370966584 注意下方法名字,我指的是updateNavigationBarWithFromVC:toVC:progress:方法。
@banchichen 是设置了 但是还是不行 我用作者的Demo从首页直接 present TZImagePickerController
我看到 会闪下黑色的背景
@370966584 我这可以的,就是作者最新的Demo代码。只改动我上面说的2处地方,黑名单是生效的。
你是不是漏看了第一条,没把TZImagePickerController放到黑名单里?
@banchichen 可以了多谢TZ大神 不过 我就有点纳闷 为什么作者Demo中黑名单没有TZImagePickerController,SpecialController present也没问题,直接在首页present就有问题了 矮
// WRNavigationBar 不会对 blackList 中的控制器有影响
[WRNavigationBar wr_setBlacklist:@[@"TZImagePickerController"]];
然后按照
- (void)updateNavigationBarWithFromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC progress:(CGFloat)progress {
if (![WRNavigationBar needUpdateNavigationBar:toVC]) {
return;
}
// 源码中非黑名单的正常处理
}还是不行呀
只需要设置这个就可以了,亲测有效
// WRNavigationBar 不会对 blackList 中的控制器有影响
[WRNavigationBar wr_setBlacklist:@[@"SpecialController",
@"TZPhotoPickerController",
@"TZGifPhotoPreviewController",
@"TZAlbumPickerController",
@"TZPhotoPreviewController",
@"TZVideoPlayerController"]];
只有第一次生效了,点击取消在弹出来之后还是白色
- (void)viewDidLoad {
[super viewDidLoad];
self.needShowStatusBar = ![UIApplication sharedApplication].statusBarHidden;
self.view.backgroundColor = [UIColor whiteColor];
// 建议作者把下面两句话去掉
// self.navigationBar.barStyle = UIBarStyleBlack;
// self.navigationBar.translucent = YES;
}
[WRNavigationBar wr_setBlacklist:@[@"TZImagePickerController",
@"SpecialController",
@"TZPhotoPickerController",
@"TZGifPhotoPreviewController",
@"TZAlbumPickerController",
@"TZPhotoPreviewController",
@"TZVideoPlayerController"]];
-
(void)updateNavigationBarWithFromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC progress:(CGFloat)progress {
if (![WRNavigationBar needUpdateNavigationBar:toVC]) {
return;
}// change navBarBarTintColor
UIColor *fromBarTintColor = [fromVC wr_navBarBarTintColor];
UIColor *toBarTintColor = [toVC wr_navBarBarTintColor];UIColor *newBarTintColor = [WRNavigationBar middleColor:fromBarTintColor toColor:toBarTintColor percent:progress];
if ([WRNavigationBar needUpdateNavigationBar:fromVC] || [WRNavigationBar needUpdateNavigationBar:toVC]) {
[self setNeedsNavigationBarUpdateForBarTintColor:newBarTintColor];
}// change navBarTintColor
UIColor *fromTintColor = [fromVC wr_navBarTintColor];
UIColor *toTintColor = [toVC wr_navBarTintColor];
UIColor *newTintColor = [WRNavigationBar middleColor:fromTintColor toColor:toTintColor percent:progress];
if ([WRNavigationBar needUpdateNavigationBar:fromVC]) {
[self setNeedsNavigationBarUpdateForTintColor:newTintColor];
}// change navBarTitleColor(在wr_popToViewController:animated:方法中直接改变标题颜色)
UIColor *fromTitleColor = [fromVC wr_navBarTitleColor];
UIColor *toTitleColor = [toVC wr_navBarTitleColor];
UIColor *newTitleColor = [WRNavigationBar middleColor:fromTitleColor toColor:toTitleColor percent:progress];
[self setNeedsNavigationBarUpdateForTitleColor:newTitleColor];// change navBar _UIBarBackground alpha
CGFloat fromBarBackgroundAlpha = [fromVC wr_navBarBackgroundAlpha];
CGFloat toBarBackgroundAlpha = [toVC wr_navBarBackgroundAlpha];
CGFloat newBarBackgroundAlpha = [WRNavigationBar middleAlpha:fromBarBackgroundAlpha toAlpha:toBarBackgroundAlpha percent:progress];
[self setNeedsNavigationBarUpdateForBarBackgroundAlpha:newBarBackgroundAlpha];
}
突然发现导航栏都白了,全局黑名单后,再加入return,效果明显!!!!