gpt4 book ai didi

ios - NativeScript ActionBar 不透明度

转载 作者:行者123 更新时间:2023-11-29 00:56:21 28 4
gpt4 key购买 nike

我尝试更改操作栏的不透明度。为了测试,我尝试通过 native 方法更改颜色,但这不起作用。

我不明白为什么,其他 native 函数(例如 UIAlert)工作正常。我没有错误或其他任何问题,只是操作栏看起来像这样:

enter image description here

我的目标是完全透明的,因为背景有渐变。

这是我的页面加载函数:

loaded(args){
let page = <Page>args.object;
page.bindingContext = appViewModel;

if (page.ios) {
var controller = frameModule.topmost().ios.controller;
var navigationBar = controller.navigationBar;
navigationBar.barTintColor = UIColor.blueColor();
}
}

感谢帮助

更新

我的ts代码:

var frameModule = require("ui/frame");
import {topmost} from "ui/frame";
import {Page} from "ui/page";
import {Observable, EventData} from "data/observable";
import {View} from "ui/core/view";

let appViewModel = new Observable({selectedPage: "dashboard"});
export abstract class BasePage {
//implement this function in the inheriting pages to set their specific binding context
abstract mainContentLoaded(args:EventData);

loaded(args){
let page = <Page>args.object;
page.bindingContext = appViewModel;

if (page.ios) {
frameModule.topmost().ios.navBarVisibility = "always";

page.ios.title = "Test Application";

var controller = frameModule.topmost().ios.controller;

var navBar = controller.navigationBar;
navBar.barTintColor = UIColor.redColor();
navBar.navigationBarHidden = false;
navBar.barStyle = UIBarStyle.UIBarStyleBlackTranslucent;
}

}

toggleDrawer(){
let page = <Page>topmost().currentPage;
let drawer = <any>page.getViewById("sidebar");
drawer.toggleDrawerState();
}
navigate(args){
let pageName = args.view.text.toLowerCase();
appViewModel.set("selectedPage", pageName);
topmost().navigate("modules/" + pageName + "/" + pageName);
}

}

我的 XML:

<page
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:drawer="nativescript-telerik-ui/sidedrawer"
xmlns:widgets="shared/widgets"
loaded="loaded">

<page.actionBar>
<action-bar>
<navigation-button icon="res://ic_menu" tap="toggleDrawer" ios:visibility="collapsed" />
<action-bar.actionItems>
<ios>
<action-item icon="res://ic_menu" ios.position="left" tap="toggleDrawer" />
</ios>
</action-bar.actionItems>
</action-bar>
</page.actionBar>

<drawer:rad-side-drawer id="sidebar">
<drawer:rad-side-drawer.mainContent>

</drawer:rad-side-drawer.mainContent>
<drawer:rad-side-drawer.drawerContent>
<widgets:drawer-content />
</drawer:rad-side-drawer.drawerContent>
</drawer:rad-side-drawer>

</page>

最佳答案

以下解决方案适合我(iOS 9.3 和 NativeScript 2.0.1)

if (page.ios) {
frameModule.topmost().ios.navBarVisibility = "always";

page.ios.title = "Test Application";

var controller = frameModule.topmost().ios.controller;

var navBar = controller.navigationBar;
navBar.barTintColor = UIColor.redColor();
navBar.navigationBarHidden = false;
navBar.barStyle = UIBarStyle.UIBarStyleBlackTranslucent;
}

关于ios - NativeScript ActionBar 不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37597053/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com