【问题标题】:How to modify native-base datepicker's background?如何修改原生日期选择器的背景?
【发布时间】:2020-02-28 08:59:22
【问题描述】:

在 iOS 暗模式下,日期选择器似乎存在一个普遍问题(并非特定于原生基础)。

为了解决这个问题,我想设置模态框的背景颜色。但我不知道它是否可能......

import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { DatePicker } from 'native-base';

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = { chosenDate: new Date() };

    this.setDate = this.setDate.bind(this);
  }
  setDate(newDate) {
    this.setState({ chosenDate: newDate });
  }
  render() {
    return (
      <View style={styles.container}>
        <Text />
        <Text />
        <Text />
        <DatePicker
          defaultDate={new Date(1976, 12, 23)}
          minimumDate={new Date(1940, 1, 1)}
          maximumDate={new Date(2040, 12, 31)}
          locale={'en'}
          timeZoneOffsetInMinutes={undefined}
          modalTransparent={false}
          animationType={'fade'}
          androidMode={'default'}
          placeHolderText="Select date"
          textStyle={{ color: 'green' }}
          placeHolderTextStyle={{ color: '#d3d3d3' }}
          onDateChange={this.setDate}
        />
        <Text>Date: {this.state.chosenDate.toString().substr(4, 12)}</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
});

代码是世博小吃here,遇到问题可以试试iOS深色模式和浅色模式。

【问题讨论】:

    标签: react-native datepicker native-base ios-darkmode


    【解决方案1】:

    您可以通过自定义主题变量来做到这一点。

    有关参考,请参阅这些链接

    https://docs.nativebase.io/docs/ThemeVariables.html

    https://docs.nativebase.io/Customize.html#theme-and-variables-headref

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 1970-01-01
      • 2021-02-24
      • 1970-01-01
      • 2022-01-15
      • 2019-11-30
      相关资源
      最近更新 更多