IOS 的 ProgressViewOffset 刷新控件 React Native

ProgressViewOffset for IOS Refresh Control React Native

我有隐藏在卷轴上的 header,所以我使用 ProgressViewOffset 在 header.
下方显示刷新控件加载器 它在 Android 上运行良好。但是在 IOS 中我们不支持偏移。但我最终使用了 contentInset 和 contentOffset 但我没有得到它。

          refreshControl: (
        <RefreshControl
          // refreshing
          refreshing={this.props.isloading}
          onRefresh={this.onRefresh}
          progressViewOffset={200}
          />
      ),
      contentInset: {top: 200},
      onMomentumScrollBegin,
      onMomentumScrollEnd,
      onScrollEndDrag,
      ItemSeparatorComponent: this.renderSeparator,
      onScrollEventThrottle: 16,
      automaticallyAdjustContentInsets: false, 
      contentOffset: {x: 0, y: -200},

PS: 当我使用 contentContainerStyle 和 contentInset 时,refreshcontrol 和内容之间有一个 space...

我通过将 HEADER_HEIGHT 传递给 contentInset、contentOffset 而不使用 contentContainerStyle 来修复它。

<AnimatedScrollView
  contentContainerStyle={{
    paddingTop: Platform.OS === 'ios' ? 0 : HEADER_HEIGHT,
  }}
  scrollEventThrottle={16}
  onScroll={Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.state.scrollAnim } } }],
    { useNativeDriver: true }
  )}
  contentInset={{ top: HEADER_HEIGHT }}
  contentOffset={{ x: 0, y: -HEADER_HEIGHT }}
  refreshControl={
    <RefreshControl
      refreshing={this.state.refreshing}
      onRefresh={this.onrefresh}
      progressViewOffset={HEADER_HEIGHT}
    />
  }
  automaticallyAdjustContentInsets={false}

</AnimatedScrollView>

运行 Snack 上的代码:https://snack.expo.io/@legowtham/9c7a01

PS:当我们使用自定义动画 header 时,pull-to-refresh 加载程序会导致 header 在加载程序停止后反弹。如果您不喜欢这个动画问题,请使用 Animated.diffClamp 来避免这种情况。 这篇文章可能有用:https://medium.com/appandflow/react-native-collapsible-navbar-e51a049b560a