Skip to content
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

UIButton background color blending #339

Open
Emailrus opened this issue Mar 14, 2016 · 6 comments
Open

UIButton background color blending #339

Emailrus opened this issue Mar 14, 2016 · 6 comments

Comments

@Emailrus
Copy link

Might be related to this issue

When you have a button with defined non-clear backgroundColor (for example in interface builder), any background-color style with translucency will be blending with it, which is undesired.

Possible solutions might be reseting backgroundColor to clear in NUIButtonRenderer or give user opportunity to set backgroundColor of a view in .nss file.

@Stunner
Copy link
Collaborator

Stunner commented Mar 14, 2016

This talks about solving that very problem (for UIButton). However, that capability is not yet finished to the point where it may be merged back into this repo; but I have successfully used that code in a few apps of mine running in production. Hopefully, that may suffice for the time being.

@Emailrus
Copy link
Author

Having custom blocks for styles is ok, but I think this particular situation should be working out of a box.

@Stunner
Copy link
Collaborator

Stunner commented Mar 14, 2016

Possible solutions might be reseting backgroundColor to clear in NUIButtonRenderer or give user opportunity to set backgroundColor of a view in .nss file.

Background color can be set on UIView instances from .nss file. The color transparency blending issue isn't the only problem as it boils down to a lack of a setColor:forState: method for the UIButton class. The lack of this method causes NUI to be forced to do a hack where it instead tints an image to the specified color, which causes untrue colors to be set for UIButton instances with NUI. The best thing we can possibly do in this case is to leave it up to the developer to do exactly what (s)he would like to in that instance. Thus, the (main) reason why I created overridable properties.

If you have a good idea for what the default behavior should be, I'd be happy to hear it. But it is important to realize people will expect it to more-or-less work out of the box. And although the current solution isn't ideal, it does manage to make the most of what we have access to; all while preventing overly unexpected behavior.

@Emailrus
Copy link
Author

As I said, reset backgroundColor to clear color in NUIButtonRenderer, if background-color related properties have any value

@Stunner
Copy link
Collaborator

Stunner commented Mar 14, 2016

Sure, that's a band aid fix, but you are still going to notice the color
specified in the style sheet as slightly off due to the image color tinting
hack that NUI currently uses.

Since I take it your are currently experiencing this issue and can readily
test it. I'll leave it to you to submit a pull request.
On Mon, Mar 14, 2016 at 4:13 AM Emil notifications@github.com wrote:

As I said, reset backgroundColor to clear color in NUIButtonRenderer, if
background-color related properties have any value


Reply to this email directly or view it on GitHub
#339 (comment).

@Emailrus
Copy link
Author

Hmm, now I'm not sure if I understood you correctly before. What do you mean by color tinting hack being slightly off? From what I see NUIConverter creates UIImage based on the color you specify in nss file and then NUIButtonRenderer uses it as a background image in UIButton. Is there something I missed?

As for me, I just made a workaround by setting background color as clear in my xib files.

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

No branches or pull requests

2 participants