mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:51:27 +08:00
fix(ios): backport: actionBar to use appearance api on ios13+ (#9530)
This commit is contained in:
@ -349,7 +349,7 @@ export class ActionBar extends ActionBarBase {
|
||||
this.setColor(navBar, color);
|
||||
|
||||
const bgColor = <Color>this.backgroundColor;
|
||||
navBar.barTintColor = bgColor ? bgColor.ios : null;
|
||||
this.setBackgroundColor(navBar, bgColor);
|
||||
}
|
||||
|
||||
private setColor(navBar: UINavigationBar, color?: Color) {
|
||||
@ -371,6 +371,25 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
private setBackgroundColor(navBar: UINavigationBar, color?: UIColor | Color) {
|
||||
if (!navBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
const color_ = color instanceof Color ? color.ios : color;
|
||||
if (majorVersion >= 13) {
|
||||
const appearance = navBar.standardAppearance ?? UINavigationBarAppearance.new();
|
||||
// appearance.configureWithOpaqueBackground();
|
||||
appearance.backgroundColor = color_;
|
||||
navBar.standardAppearance = appearance;
|
||||
navBar.compactAppearance = appearance;
|
||||
navBar.scrollEdgeAppearance = appearance;
|
||||
} else {
|
||||
// legacy styling
|
||||
navBar.barTintColor = color_;
|
||||
}
|
||||
}
|
||||
|
||||
public _onTitlePropertyChanged() {
|
||||
const page = this.page;
|
||||
if (!page) {
|
||||
@ -467,12 +486,9 @@ export class ActionBar extends ActionBarBase {
|
||||
// CssAnimationProperty use default value form their constructor.
|
||||
return null;
|
||||
}
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](color: UIColor | Color) {
|
||||
const navBar = this.navBar;
|
||||
if (navBar) {
|
||||
const color = value instanceof Color ? value.ios : value;
|
||||
navBar.barTintColor = color;
|
||||
}
|
||||
this.setBackgroundColor(navBar, color);
|
||||
}
|
||||
|
||||
[backgroundInternalProperty.getDefault](): UIColor {
|
||||
|
Reference in New Issue
Block a user