mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
feat(switch): add property for off state background color (#7138)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import {
|
||||
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
|
||||
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty, offBackgroundColorProperty
|
||||
} from "./switch-common";
|
||||
|
||||
export * from "./switch-common";
|
||||
@ -95,4 +95,15 @@ export class Switch extends SwitchBase {
|
||||
[backgroundInternalProperty.setNative](value: any) {
|
||||
//
|
||||
}
|
||||
|
||||
[offBackgroundColorProperty.getDefault](): UIColor {
|
||||
return this.nativeViewProtected.backgroundColor;
|
||||
}
|
||||
[offBackgroundColorProperty.setNative](value: Color | UIColor) {
|
||||
const nativeValue = value instanceof Color ? value.ios : value;
|
||||
|
||||
this.nativeViewProtected.tintColor = nativeValue;
|
||||
this.nativeViewProtected.backgroundColor = nativeValue;
|
||||
this.nativeViewProtected.layer.cornerRadius = this.nativeViewProtected.frame.size.height / 2;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user