美文网首页
0803日记

0803日记

作者: KallyKello | 来源:发表于2018-08-03 09:23 被阅读0次

    用时候使用第三方的时候无法修改他的导航栏可以写一个分类进行拦截,将导航栏调整为符合系统风格,融云在进入的定位界面是“取消”和“发送”按钮为白色,导致看不见,点击位置“消息”进入定位界面导航的返回按钮失效,可以继承融云原来的RCLocationViewController,在进行重写

    #import "UIViewController+LZSwizzling.h"
    
    @implementation UIViewController (LZSwizzling)
    
    + (void)load {
        [super load];
        //原本的willAppear方法
        Method willAppearOriginal = class_getInstanceMethod([self class], @selector(viewWillAppear:));
        //我们的willAppear方法
        Method willAppearNew = class_getInstanceMethod([self class], @selector(swizzlingViewWillAppear:));
        //交换
        if (!class_addMethod([self class], @selector(viewWillAppear:), method_getImplementation(willAppearNew), method_getTypeEncoding(willAppearNew))) {
            method_exchangeImplementations(willAppearOriginal, willAppearNew);
        }
    }
    
    - (void)swizzlingViewWillAppear:(BOOL)animated {
        [self swizzlingViewWillAppear:animated];
        if ([self isMemberOfClass:NSClassFromString(@"RCPhotosPickerController")]) {
            [self configureRongCloudNavigation];
            UICollectionView *collectionView = self.view.subviews.firstObject;
            collectionView.contentInset = UIEdgeInsetsMake(NAVIGATION_HEIGHT_S, 0, 0, 0);
        }
        if ([self isMemberOfClass:NSClassFromString(@"RCAlumListTableViewController")] || [self isMemberOfClass:NSClassFromString(@"RCLocationPickerViewController")] || [self isMemberOfClass:NSClassFromString(@"PUPhotoPickerHostViewController")]) {
            [self configureRongCloudNavigation];
        }
    }
    
    - (void)configureRongCloudNavigation {
        self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    //    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:kNavImageName(@"nav_bg")] forBarMetrics:UIBarMetricsDefault];
        self.navigationController.navigationBar.tintColor = MAIN_COLOR;
        self.navigationItem.leftBarButtonItem.tintColor = MAIN_COLOR;
        self.navigationItem.rightBarButtonItem.tintColor = MAIN_COLOR;
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:MAIN_COLOR, NSFontAttributeName:[UIFont boldSystemFontOfSize:17]}];
    }
    
    @end
    
    

    相关文章

      网友评论

          本文标题:0803日记

          本文链接:https://www.haomeiwen.com/subject/snzevftx.html