原文链接:http://haxecoder.com/post.php?id=74
参考资源:http://www.openfl.org/learn/
There are several ways to style components in HaxeUI.

Fortunately, HaxeUI tries to follow the convenient CSS + HTML pattern so if you're familiar with those, you'll have no problem grasping this concept quickly.

You can style controls in code by accessing and setting values to the properties of their "style" property directly. This is the most obvious but the least convenient way to change the appearance of a component, so let's jump right into the CSS approach.

You can create CSS descriptions using the static StyleManager class, add them to the layout XML in a "style" node, or store them in a separate CSS file and load that.

To add a style description in code, use the StyleManager.instance.addStyle() method.

Selectors follow the usual CSS syntax, so you can access all components of the type Button and apply the style to them. For example:

StyleManager.instance.addStyle("Button", new Style({
color: 0xFF0000,
fontSize: 20,
}));
HaxeUI styling
If you want to style an individual control with a specific ID, use the # selector:

StyleManager.instance.addStyle("#myButton", new Style({
color: 0xFF0000,
fontSize: 20,
}));
HaxeUI styling
Similarly to the "class" attribute in HTML, you can apply styles to components using the "styleName" attribute.