4

Hi Nativescript Community,

I can`t get the transparency to work on the ActionBar using Nativescript in combination with Angular. I have found serval topics like this one, but no one has a working example using Angular. Would somebody like to send me a working example of a transparent ActionBar background using Angular? Finally i would like to be able to change the transparency upon scrolling.

Some relevant topics (but without working angular example):

  1. https://github.com/3rror404/ns-fading-actionbar
  2. Adding view to NativeScript ActionBar breaks navigation
  3. https://www.nativescript.org/blog/how-to-match-a-nativescript-actionbar-s-color-on-ios
  4. https://discourse.nativescript.org/t/scrolling-behind-transparent-actionbar/2133
  5. https://discourse.nativescript.org/t/tranparent-action-bar/3413
  6. https://github.com/NativeScript/NativeScript/issues/2669

Regards,

Timber

Timber
  • 41
  • 4
  • I swear this is making me go crazy, I've looked at every link and article, it still is translucent. I'm glad I'm not the only one who is struggling with this. – David Rees Apr 09 '18 at 03:05
  • Well apparently no one seems to have the correct answer to this, multiple view but no answers:( – Timber Apr 10 '18 at 08:06
  • I think you should hide the action bar as shown in example https://play.nativescript.org/?template=play-tsc&id=Y4fVGt&v=16 by which the action bar would be transparent. You can customise the top of the page to have any buttons or labels. – Rakesh Mar 18 '19 at 13:42

2 Answers2

0

You can use anything as a action-bar. Put a label on top 7% of a gridlayout and there you go. I don't know if actionbar tools would work or not but you can try it out.

emrexyz
  • 1
  • 2
0

Here is an example for iOS.

import { topmost, Color } from "tns-core-modules/ui/frame";

declare let UIBarMetrics, UIBarStyle, UIImage;

makeActionBarTransparent() : void {
    let navbar = topmost().ios.controller.navigationBar;
    navbar.barStyle = UIBarStyle.BlackTranslucent;
    navbar.setBackgroundImageForBarMetrics(UIImage.new(), UIBarMetrics.Default);
    navbar.shadowImage = UIImage.new();
    navbar.translucent = true;
    navbar.tintColor = new Color('white').ios;
}

But it seems that when you modify the action bar in a page, action bar is modified in other pages too. If this is not the desired behavior for you, you can hide the action bar and use custom elements. For example, create a transparent stack-layout with action icons on it.

You can hide the actionbar like this:

import { Page } from "tns-core-modules/ui/page";

constructor(
    private page : Page
) {}

ngAfterViewInit() : void {
    this.page.actionBarHidden = true;
}
zarax
  • 871
  • 1
  • 10
  • 30