问题
I have a button with an icon. I want to have the button in gray so I change the chromeColor
but when I do that, the icon became darker.
On the left the button without changing the color, on the right, the gray button with and darker icon.
How can I have a gray button without changing the icon color
?
回答1:
You can do this by modifying the skin class and adding "iconDisplay" to the exclusion array. At the end the line should look like this:
static private const exclusions:Array = ["labelDisplay","iconDisplay"];
Hope this helps.
回答2:
What SDK are you using? If you are in the 4.* range, then I think you should look at applying a custom skin on the button.
回答3:
As said, it can be done through a custom skin. To create a custom skin with flash builder:
- Create a new package "skins" inside "src".
- Right click on skins and click on "New > MXML Skin".
- Give it a name, for instance "CustomButtonSkin".
- Pick the host component "spark.components.Button".
- Create as copy of "spark.skins.spark.ButtonSkin".
Add "iconDisplay" to the "exclusions:Array".
static private const exclusions:Array = ["labelDisplay", "iconDisplay"];
Apply the new custom skin to your buttons.
<s:Button id="MyCustomButton" skinClass="skins.CustomButtonSkin" icon="@Embed(source='...')" />
来源:https://stackoverflow.com/questions/7442216/color-of-icon-when-changing-color-of-button