Description
I have found that after a Button is created on iOS, it is not possible to change the backgroundColor of it. It doesn't change if you change the CSS class nor does accessing the background color like btn.backgroundColor = new Color('blue')
The below only works on Android, where as on iOS the button background color does not change after it is first set:
const btn1 = new Button();
const btn2 = new Button();
let toggle = true;
// Background color doesn't change after it's created
btn1.on("tap", (_args) => {
if (toggle) {
btn1.color = new Color("red");
btn1.backgroundColor = new Color("blue");
toggle = false;
} else {
btn2.color = new Color("yellow");
btn2.backgroundColor = new Color("black");
toggle = true;
}
});
stackLayout.addChild(btn1);
stackLayout.addChild(btn1);
}
I have had tons of issues on iOS when changing between dark and light themes while the app is running especially with buttons not responding to color changes and I think this might be the culprit. It appears that the backgroundColor property is not implemented on the iOS Button view.
I have made a PR to fix this in @nativescript/core.