我想在DateChooser/CalendarLayout中查看平日和周末日的不同颜色。我也想这样使用自定义样式名(例如实现:?“weekColor”和“weekendColor”Flex DateChooser - 星期/周末天的字体颜色差异
不知道如何可以做到这一点
欢呼, 里克
我想在DateChooser/CalendarLayout中查看平日和周末日的不同颜色。我也想这样使用自定义样式名(例如实现:?“weekColor”和“weekendColor”Flex DateChooser - 星期/周末天的字体颜色差异
不知道如何可以做到这一点
欢呼, 里克
我做了什么类似于客户端,方法是扩展CalendarLayout类以接受这些样式,并修改相关日子的样式,然后扩展DateChooser以接受相同的样式,并将它们传递到您的新CalendarLayout类。
它是单调乏味;而且你很可能会遇到私有变量i ssues;但它是可行的。
这花了我几天,但我发现了它。所以为了将来的参考:这里是我的解决方案:
我扩展了DateChooser并在函数updateDisplayList(w:Number,h:Number)上添加了覆盖(在此函数中设置了SMTWTFS日期名称)。
在updateDisplayList中,您可以获取mx_internal :: dateGrid.dayBlockArrays [column] [row]包含CalendarLayout的所有值。在该数组/数组中,每列上的第一行是SMTWTFS天数中的一行。其他行是dayNumbers。一旦我发现这是一个决定什么是周末的日子,并相应地调整颜色的问题。正如我在下面:
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
// Now the dayBlocksArray has been filled. The Array looks as follows
// dayBlocksArray["rows"]["columns] .... therefor [i][0 (zero)] will always get the dayNames (SMTWTFS)
// Compare the dayNames with the set this.dayNames (which always start with sunday) and find the weekend days
var colIndex:uint = 0;
var rowIndex:uint = 1; // The first row (SMTWTFS) is handled seperately
var currentColumn:Array;
var dayName:UITextField;
var backgroundColor:uint = this.getStyle("dayNamesBackgroundColor");
var isWeekendCol:Boolean = false;
var currentTextFormat:TextFormat;
// When the style is not found the default of white will be used.
if (!backgroundColor)
{
backgroundColor = 0xFFFFFF;
}
for (colIndex; colIndex < 7; colIndex++)
{
// First determine if the first item in this row (SMTWTFS) is a week/weekend day
currentColumn = mx_internal::dateGrid.dayBlocksArray[colIndex];
dayName = currentColumn[0];
// Determine if this is a weekend row
// The dayNames array is fixed in the order of index 0 = sunday and index 6 = saturday.
// Therefor check of the text value of the current dayName is equal to either of
// those two. If it is we are dealing with a weekend column
isWeekendCol = dayName.text == this.dayNames[0] || dayName.text == this.dayNames[6];
if (isWeekendCol)
{
// Set the color
currentTextFormat = dayName.getTextFormat();
currentTextFormat.color = getStyle("weekendHeaderColor");
dayName.setTextFormat(currentTextFormat);
// Set the background color
dayName.background = true;
dayName.backgroundColor = backgroundColor;
}
else
{
currentTextFormat = dayName.getTextFormat();
currentTextFormat.color = getStyle("weekHeaderColor");
dayName.setTextFormat(currentTextFormat);
// Set the background color
dayName.background = true;
dayName.backgroundColor = backgroundColor;
}
// Reset the rowIndex
rowIndex = 1;
// Now go through all the other rows of this column
for (rowIndex; rowIndex < currentColumn.length; rowIndex++)
{
dayName = currentColumn[rowIndex];
if (isWeekendCol)
{
dayName.setColor(getStyle("weekendColor"));
}
else
{
dayName.setColor(getStyle("weekColor"));
}
}
}
}
在CSS文件中添加以下样式:
DateChooser {
cornerRadius:0; headerColors:#FFFFFF,#FFFFFF; todayColor:#00448c; border-style:none; dropShadowEnabled:false; fontFamily:myGeorgia; dayNamesBackgroundColor:#ECECEC; weekHeaderColor:#444444; weekendHeaderColor:#DDDDDD; weekColor:#00317F; weekendColor:#DDDDDD; headerStyleName:“dateChooserHeaderStyle”;
comboBoxStyleName:“comboBoxStyleName”; }
最有趣这里的风格是自定义样式“dayNamesBackgroundColor”(这是用来给背景色的SMTWTFS集)和自定义样式“weekendHeaderColor”,“weekHeaderColor”,“weekColor”,“weekendColor “
我读了上面的方法,这些颜色以获取在周/周末颜色的差异完全控制,其中SMTWTFS集可以得到不同的颜色比天数
希望这将帮助其他人的未来。花了我很多时间弄清楚:)
确实很乏味......它几乎看起来像Adobe不希望你触摸CalendarLayout,几乎所有东西都是该类中的私有。至少我很高兴听到我走在正确的轨道上。 – 2011-05-06 06:45:58