全部服务产品
开发者频道
服务升级
登录
自定义UI控件
下载开发文档

导航中自定义UI控件是指导航页面底部UI支持添加自定义控件,仅支持摩托车/货车。默认情况下,摩托车和货车是经典底部样式。下面介绍这种样式下支持的自定义UI控件的能力。

customcontrol.png

经典底部样式

货车和摩托车导航中底部UI只支持经典底部样式。开发者可以在底部剩余时间距离视图的下面和上面添加自定义视图。

实现自定义视图,需要执行以下操作:

(1)设置好自定义视图的高度

(2)创建自定义视图,添加到主视图中

(3)设置车标的偏移量

具体使用方式:

1. 设置自定义视图高度
#define TRUCK_BOTTOMHEIGHT 50
#define TRUCK_NAVILOCATIONOFFSET 0
#define TRUCK_TOOLBARVIEWTOPSPACE 40
#define CAR_BOTTOMHEIGHT 0
#define CAR_NAVILOCATIONOFFSET 50
#define CAR_TOOLBARVIEWTOPSPACE 40
2. 创建自定义视图,添加到主视图
-(void)enterNavi {
BNaviService_Strategy.bottomButtonHeight = TRUCK_BOTTOMHEIGHT;
BNaviService_Strategy.toolBarViewTopSpace = TRUCK_TOOLBARVIEWTOPSPACE;
BNaviService_Strategy.naviLocationOffset = TRUCK_NAVILOCATIONOFFSET;
[BNaviService_UI showPage:BNaviUI_NormalNavi delegate:self extParams:@{BNaviUI_NormalNavi_TypeKey: @(BN_NaviTypeTruck)}];
}
-(void)onHandleNaviViewDidLoad:(UIView *)naviView {
if (naviView) {
if ([UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeRight || [UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeLeft) {
//当前横屏
CGRect naviFrame = naviView.frame;
naviFrame.size.width = naviView.frame.size.height;
naviFrame.size.height = naviView.frame.size.width;
naviView.frame = naviFrame;
}
CGFloat btnHeight = 40;
__weak __typeof(UIView *) weakNaviView = naviView;
UILabel *customizeTopView = [[UILabel alloc] init];
customizeTopView.userInteractionEnabled = YES;
customizeTopView.text = @"顶部区域";
customizeTopView.textAlignment = NSTextAlignmentCenter;
customizeTopView.backgroundColor = RGBA(0, 191, 255, 1);
[weakNaviView addSubview:customizeTopView];
customizeTopView.frame = CGRectMake(0, BNaviService_Strategy.truckBottomButtonTop - btnHeight -5, weakNaviView.width, btnHeight);
UILabel *customizeBottomView = [[UILabel alloc] init];
customizeBottomView.text = @"底部自定义区域";
customizeBottomView.textColor = [UIColor whiteColor];
customizeBottomView.textAlignment = NSTextAlignmentCenter;
customizeBottomView.backgroundColor = RGBA(0, 139, 139, 1);
[weakNaviView addSubview:customizeBottomView];
customizeBottomView.frame = CGRectMake(0, weakNaviView.height - BNaviService_Strategy.bottomButtonHeight, weakNaviView.width, BNaviService_Strategy.bottomButtonHeight);
customizeBottomView.layer.masksToBounds = YES;
customizeBottomView.layer.cornerRadius = 6;
customizeTopView.layer.masksToBounds = YES;
customizeTopView.layer.cornerRadius = 6;
}
}

上一篇

自定义标注

下一篇

其他自定义能力

本篇文章对您是否有帮助?