uni-app 动态设置 原生导航栏的button 原生导航栏字体图标显示为问号或方框的问题(自定义导航栏字体图标在IOS端是问号或方框)

uni-app原生导航栏字体图标变成问号

项目中向根据视频是否播放来控制导航栏中一个button是否显示,在一开始是这么写的

isPlay: {
	immediate: true,
	handler(isPlay) {
		//#ifdef APP-PLUS
		var currentWebview = this.$mp.page.$getAppWebview();
		if (isPlay) {
			currentWebview.setTitleNViewButtonStyle(3, {
				width: '60px'
			})
		} else {
			currentWebview.setTitleNViewButtonStyle(3, {
				width: '0'
			})
		}
		//#endif
	}
}

一开始在监听中是这样写的,在安卓中能正常跑,但是在ios端就出问题了。原生导航栏中的字体图标变成了问号
在这里插入图片描述
在网上想找解决方法也没又找到有效的,最后发现了监听这里可能会有问题,注释这段代码后就显示正常了,但还是需要监听button显示,所以换了写法。

isPlay: {
	immediate: true,
	handler(isPlay) {
		console.log('isPlay', isPlay)
		//#ifdef APP-PLUS
		var currentWebview = this.$mp.page.$getAppWebview();
		var tn = currentWebview.getStyle().titleNView;
		tn.buttons[3].text = isPlay ? "\ue607" : "";
		tn.buttons[3].background = isPlay ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)"
		currentWebview.setStyle({
			titleNView: tn
		});
		//#endif
	}
}

最后,终于好了。

在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值