【问题标题】:Change large actionbar title font更改大动作栏标题字体
【发布时间】:2019-09-14 12:11:56
【问题描述】:

是否可以更改大的操作栏标题字体?

我正在使用这样的大条:

 const actionBar = <ActionBar>this.viewContainerRef.element.nativeElement;

        actionBar.on("loaded", (args) => {
            if (actionBar.ios) {
                const navigationBar: UINavigationBar = actionBar.ios;
                const color = new Color("white");

                navigationBar.prefersLargeTitles = true;
                navigationBar.tintColor = color.ios;
                navigationBar.barTintColor = color.ios;

                navigationBar.titleTextAttributes = <any>{
                    [NSForegroundColorAttributeName]: color.ios
                };

                navigationBar.largeTitleTextAttributes = <any>{
                    [NSForegroundColorAttributeName]: color.ios
                };
            }
        });

我已通过 CSS 将自定义字体应用于操作栏。但这种变化并没有体现在大吧上。当我关闭大栏时,标题是自定义字体。

【问题讨论】:

  • 我没有看到任何与上面字体相关的代码,你能分享一下你正在尝试更改操作栏字体的确切代码吗?

标签: nativescript nativescript-angular


【解决方案1】:

您可以通过在模板元素中使用FormattedString 标记来更改字体样式,并添加一些Spans 来获取您的格式。 You can check de docs here.

要在 TS 中执行此操作,请尝试添加以下代码:

const format:FormattedString = new FormattedString();
const span:Span = new Span();
span.fontFamily = 'name-your-font';

...然后将Span 放入FormattedString 中,将FormattedString 放入您的ActionBar 中。

希望对您有所帮助!如果没有,请告诉我!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    • 2017-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    相关资源
    最近更新 更多