在flex中更改单个标签样式 [英] Changing individual tab style in flex

查看:127
本文介绍了在flex中更改单个标签样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  var cssStyle:CSSStyleDeclaration 

我已经想出了一种在运行时改变标签样式的方法。 = StyleManager.getStyleDeclaration(。MyTabs);
cssStyle.setStyle(borderColor,red);

但是这里.MyTabs类适用于第一个和最后一个选项卡之间的所有选项卡。根据getStyleDeclaration javadoc,它只接受类选择器和类型选择器,而不是id选择器。

如何在运行时更改单个标签样式< /另外一个用户指出了一个我不知何故错过的方法,允许你访问一个Tab作为一个Buttom,并从那里设计它。

  var t:Button = theTabs.getTabAt(index); 

Tab扩展了Button,所以可能有些东西需要下面的解决方案,样式这应该是足够的。






@ Sebastian的答案适用于TabBar,我知道您没有,作为这是你问的第三个相同的问题。为了在TabNavigator上设置选项卡的样式,您需要访问内部的TabBar。

  //此导入可能不会自动执行,为你完成
导入mx.controls.tabBarClasses.Tab;

var t:Tab = theTabs.mx_internal :: getTabBar()。getChildAt(index);

现在您可以随意设置样式,如Sebastian的答案所示。 b $ b

I have figured out a way to change the style of tabs at run time with following logic:

var cssStyle:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".MyTabs");
  cssStyle.setStyle("borderColor", "red");

But here ".MyTabs" class is applicable to all the tabs between first and last tab. As per getStyleDeclaration javadoc, it only accepts "class selector" and "type selector" not the id selector.

How can I change the individual tab style at run time?

解决方案

Another user pointed out a method that I had somehow missed, allowing you to access a Tab as a Buttom and style it from there.

var t:Button = theTabs.getTabAt(index);

Tab extends Button, so there may be some things you would need the below solution for, but for basic styling this should be enough.


@Sebastian's answer works for a TabBar, which I know you don't have, as this is the third identical question you've asked. In order to style the tabs on a TabNavigator, you need to access the internal TabBar.

//this import may not auto-complete for you
import mx.controls.tabBarClasses.Tab;

var t:Tab = theTabs.mx_internal::getTabBar().getChildAt(index);

Now you can feel free to set the styles, as shown in Sebastian's answer.

这篇关于在flex中更改单个标签样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆