H5Plugin4NavigationBar.m 1.18 KB
Newer Older
张杰's avatar
张杰 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
//
//  H5Plugin4NavigationBar.m
//  H5Demo
//
//  Created by yangwei on 2018/1/11.
//  Copyright © 2018年 Alibaba. All rights reserved.
//

#import "H5Plugin4NavigationBar.h"

@implementation H5Plugin4NavigationBar

- (void)pluginDidLoad
{
    self.scope = kPSDScope_Scene;
    // -- 如只需修改外观,可监听如下事件
    [self.target addEventListener:kNBEvent_Scene_TitleView_Create_After
                     withListener:self
                       useCapture:NO];
    
    
    [self.target addEventListener:kNBEvent_Scene_NavigationItem_Left_Back_Create_After
                     withListener:self
                       useCapture:NO];
}

- (void)addJSApis
{
    [super addJSApis];
    // 可以在这里添加TitleView相关的自定义JSApi
}

- (void)handleEvent:(NBNavigationTitleViewEvent *)event
{
    [super handleEvent:event];
    
    if ([kNBEvent_Scene_TitleView_Create_After isEqualToString:event.eventType]) {
        // 更改已创建TitleView的样式
        NBNavigationTitleViewEvent *e = (id)event;
        [[e.titleView mainTitleLabel] setFont:[UIFont systemFontOfSize:18]];
        [[e.titleView mainTitleLabel] setTextColor:[UIColor blackColor]];
    }
}

@end