react-native-calendars 中议程组件的周六和周日的自定义文本颜色

问题描述 投票:0回答:2

我正在我的 React Native 应用程序中使用议程组件 react-native-calendars,并且我正在尝试使用主题对象自定义日期的外观。我想根据星期几设置日期的文本颜色,周六和周日为红色,其他日期为黑色。

这是我正在使用的主题对象:

const theme = {
textSectionTitleColor: (date) => {
const day = new Date(date.timestamp).getDay();
return (day === 0 || day === 6) ? ColorStyles.activeColor : '#000';
},
selectedDayBackgroundColor: ColorStyles.activeColor,
textDayFontFamily: "Quicksand-Medium",
textMonthFontFamily: "Quicksand-Medium",
textDayHeaderFontFamily: "Quicksand-Bold",
textDayFontSize: 16,
textDayHeaderFontSize: 16,
todayTextColor: ColorStyles.activeColor,
textDayColor: "#000",
textMonthColor: "#000",
textYearColor: "#000", 
};

我遵循了这种高级样式,但无法理解我应该如何按照议程进行操作。 (我能够为日历组件做到这一点)根据我的说法,议程的 style.ts 是 'stylesheet.agenda.main'.

reactjs react-native user-interface react-native-calendars
2个回答
0
投票

有一种方法可以在'theme'属性下更改它,下面是一个小例子。

theme={{
  'stylesheet.calendar.header': {
    dayTextAtIndex0: {
      color: 'red'
    },
    dayTextAtIndex6: {
      color: 'green'
    }
  }
}}

希望,这有帮助!


-1
投票

react-native-calendars 开箱即用,不提供根据特定日期更改日期文本颜色的方法。但您可以深入挖掘库并进行所需的更改。

关注此问题的评论

© www.soinside.com 2019 - 2024. All rights reserved.