gpt4 book ai didi

apache-flex - Flex DateChooser - 周/周末的字体颜色差异

转载 作者:行者123 更新时间:2023-12-04 02:39:09 27 4
gpt4 key购买 nike

我希望在工作日和周末的 DateChooser/CalendarLayout 中看到不同的颜色。我还想使用自定义样式名称(例如:“weekColor”和“weekendColor”)来实现这一点。

知道如何实现吗?

加油,瑞克

最佳答案

我花了几天时间才找到它。所以为了将来引用:这是我的解决方案:

我扩展了 DateChooser 并在函数 updateDisplayList(w:Number, h:Number) 上添加了一个重写(在此函数中已设置 SMTWTFS 日期名称)。

在 updateDisplayList 中,您可以获得包含 CalendarLayout 的所有值的 mx_internal::dateGrid.dayBlockArrays[column][row]。在那个数组/数组中,每一列的第一行是 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 {

角半径:0; header 颜色:#FFFFFF、#FFFFFF; 今天颜色:#00448c; 边框样式:无; dropShadowEnabled: false; 字体系列:myGeorgia; dayNamesBackgroundColor:#ECECEC; 周页眉颜色:#444444; 周末标题颜色:#DDDDDD; 星期颜色:#00317F; 周末颜色:#DDDDDD; headerStyleName: "dateChooserHeaderStyle";
comboBoxStyleName: "comboBoxStyleName";

这里最有趣的样式是自定义样式“dayNamesBackgroundColor”(用于为SMTWTFS集提供背景色)和自定义样式“weekendHeaderColor”、“weekHeaderColor”、“weekColor”、“weekendColor”

我在上面的方法中读取了这些颜色,以完全控制周/周末颜色的差异,其中 SMTWTFS 集可以获得与日期不同的颜色

希望这对以后的其他人有所帮助。花了我很多时间才弄明白:)

关于apache-flex - Flex DateChooser - 周/周末的字体颜色差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5897613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com