Content-Length: 264583 | pFad | http://github.com/NativeScript/NativeScript/issues/9523

C4 iOS UIButton backgroundColor does not respond to color changes · Issue #9523 · NativeScript/NativeScript · GitHub
Skip to content

iOS UIButton backgroundColor does not respond to color changes #9523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rob4226 opened this issue Aug 24, 2021 · 3 comments · Fixed by #9524
Closed

iOS UIButton backgroundColor does not respond to color changes #9523

rob4226 opened this issue Aug 24, 2021 · 3 comments · Fixed by #9524

Comments

@rob4226
Copy link
Contributor

rob4226 commented Aug 24, 2021

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.

rob4226 added a commit to rob4226/NativeScript that referenced this issue Aug 24, 2021
Currently Button on iOS doesn't respond to background color changes
after it is created. This commit implements the backgroundColorProperty
to access the native UIButton's backgroundColor property.

Fixes NativeScript#9523
@NathanWalker
Copy link
Contributor

@rob4226 thank you, possible to post a PR of the change? Looks like just a reference to a fork at moment. If post as a PR we can merge out to the next tag and it will be included in the 8.1 release soon.

@rob4226
Copy link
Contributor Author

rob4226 commented Aug 24, 2021

@NathanWalker Yes, I was just running some more tests on it, but it looks good. It's PR #9524.

Also, I created a new branch using @nativescript/core@7.3.0 and made the necessary changes to fix v7 (new branch in fork based on 7.3.0). I have a couple projects still stuck on 7 so would it be possible to also release a v7.3.1 with this fix? If you already have a branch for v7 fixes please let me know and I will base the commit on that instead of a new branch. I couldn't find a tag for v7.3.0 but I went through the changelog and commits and found it to be 7847c2f Thanks.

rob4226 added a commit to rob4226/NativeScript that referenced this issue Aug 24, 2021
Currently Button on iOS doesn't respond to background color changes
after it is created. This commit implements the backgroundColorProperty
to access the native UIButton's backgroundColor property.

Fixes NativeScript#9523
@NathanWalker
Copy link
Contributor

Sure thing we could do that, much appreciated 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/issues/9523

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy