feathers ui 换肤

Feathers是轻量级,易于定制皮肤和扩展的UI组件(适用于移动设备和桌面)。Feathers通过Starling框架,利用GPU的强大能力渲染组件,来实现更加平滑和友好的体验。

现在成为Adobe支持的类库!

特点:

跨平台
易于皮肤定制
自由和开放源码

 

这里主要讲怎么换肤,虽然官网已经提供了4套主题,但自定皮肤肯定是必需的!

以BUTTON为例子:


一,主题皮肤

AeonDesktopTheme类通过TextureAtlas设置主题皮肤
注意设置皮肤要在所有控件实例化使用之前
this.theme = new AeonDesktopTheme(this.stage);
之后才能
var mybtn:Button = new Button();
addChild(mybtn);

自定皮肤:

[Embed(source="/../assets/images/aeon.png")]
protected static const ATLAS_IMAGE:Class;

[Embed(source="/../assets/images/aeon.xml",mimeType="application/octet-stream")]
protected static const ATLAS_XML:Class;

方式一,//用于更改单个个别的主题
用户自定义皮肤可以不改变原来的资源文件,继承了自带皮肤后可以扩展自己的皮肤,举个最简单的方式:
http://wiki.starling-framework.org/feathers/extending-themes


var theme:MetalWorksMobileTheme = new MetalWorksMobileTheme();
theme.setInitializerForClass( Button, myCustomButtonInitializer, "my-custom-button" );//这里是重写主题的关键方法

var button:Button = new Button();
button.nameList.add( "my-custom-button" );//绑定你定义的主题
this.addChild( button );

//重新设置按钮主题
private function myCustomButtonInitializer( button:Button ):void
{
button.defaultSkin = new Image( upTexture );
button.downSkin = new Image( downTexture );
button.hoverSkin = new Image( hoverTexture );

button.defaultLabelProperties.textFormat = new TextFormat( "fontName", 18, 0xffffff );
}

 

另外一种方法:更改了全局的主题
继承AeonDesktopTheme类在

override protected function initialize():void
{
super.initialize();

this.setInitializerForClass( Button, myCustomButtonInitializer, ALTERNATE_NAME_MY_CUSTOM_BUTTON );
}

private function myCustomButtonInitializer( button:Button ):void
{
button.defaultSkin = new Image( upTexture );
button.downSkin = new Image( downTexture );
button.hoverSkin = new Image( hoverTexture );

button.defaultLabelProperties.textFormat = this.smallUIDarkTextFormat;
button.disabledLabelProperties.textFormat = this.smallUIDisabledTextFormat;
button.selectedDisabledLabelProperties.textFormat = this.smallUIDisabledTextFormat;
}

 

 

重写主题:
extends DisplayListWatcher :

override protected function initialize():void

 

 

 

 

 

相关资料:

http://www.starlinglib.com/wiki/News:Starling_Feathers

实例演示

posted @   itank  阅读(3302)  评论(1编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示