New ActionBar "flat" code doesn't support background-color: transparent on iOS
See original GitHub issueThis has been recently introduced in commit for #3900. While itβs a welcome step forward in CSS styling, it doesnβt work properly with ActionBar background color set to βtransparentβ because translucent
is always set to false
, which renders βtransparentβ as βblackβ. On the other hand, setting translucent
to true
doesnβt render any color, so, it seems, βtransparentβ background color needs special handling thatβs not yet present.
Below is the test app and a screenshot. The expected result is that the action bar has the same background as the body.
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="My App" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<Label text="Tap the button" class="h1 text-center"/>
<Button text="TAP" tap="{{ onTap }}" class="btn btn-primary btn-active"/>
<Label text="{{ message }}" class="h2 text-center" textWrap="true"/>
</StackLayout>
</Page>
@import 'nativescript-theme-core/css/core.light.css';
.btn {
font-size: 18;
}
.page {
background-color: turquoise;
}
.action-bar {
background-color: transparent;
color: white;
flat: true;
}
$ tns info
All NativeScript components versions information
ββββββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββ
β Component β Current version β Latest version β Information β
β nativescript β 3.1.3 β 3.1.3 β Up to date β
β tns-core-modules β 3.1.1 β 3.1.1 β Up to date β
β tns-android β β 3.1.1 β Not installed β
β tns-ios β 3.1.0 β 3.1.0 β Up to date β
ββββββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
New ActionBar "flat" code doesn't support background-color
New ActionBar "flat" code doesn't support background-color: transparent on iOS.
Read more >barTintColor not working in iOS 15 | Apple Developer Forums
Hi,. When I run the following code in application(_ :didFinishLaunchingWithOptions) in iOS 15, the bar color turns transparent (thus, showing the blackΒ ...
Read more >NativeScript ActionBar Opacity - Stack Overflow
I try to change the opacity of the actionbar. For test i try to change the color over native method but this won't...
Read more >How to Match a NativeScript ActionBar's Color on iOS
Luckily, getting the colors to match is relatively simple. The UINavigationBar has a translucent property that controls whether iOS uses theΒ ...
Read more >Apply shadow or blur effects β Figma Help Center
Note: Inner shadows don't support show behind transparent areas. ... Background blur is used a lot for interactive menus in iOS. But you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@uzarsalan Hereβs the code Iβm using in production and it performs well in both iOS 9 and 10. Iβm using it as a custom component.
shared/widgets/transparentActionBar
is the path to the file with the component. Iβm overridingupdate()
to apply my styling after NS is done applying the default. For more info see the docs http://docs.nativescript.org/ui/basics#custom-componentsComponent in
shared/widgets/transparentActionBar
:XML:
CSS:
@sserdyuk When you set the shadowImage to a new UIImage, translucency doesnβt work.
See this Stack Overflow thread: https://stackoverflow.com/questions/19226965/how-to-hide-uinavigationbar-1px-bottom-line/19227158#19227158
Iβve created a issue suggesting a way to remove the hairline border without affecting translucency here: https://github.com/NativeScript/NativeScript/issues/6620