react native RefreshControl 使用详解
2017-05-22 14:48
656 查看
RefreshControl 可以用在ScrollView或ListView 的refreshControl属性上,用于下拉刷新。
onRefresh:开始刷新时调用
refreshing:设置为true显示指示器,false:隐藏。
colors(android):指示器颜色,可以多个,循环显示。
progressBackgroundColor(android):指示器背景颜色
size(android):值:[0,1]。指示器大小,默认1,0:large
progressViewOffset(android):指示器距离顶部的位置,默认0.
tintColor(ios):指示器颜色
title(ios):指示器下显示的文字
titleColor(ios):指示器下显示的文字的颜色
github下载地址
onRefresh:开始刷新时调用
refreshing:设置为true显示指示器,false:隐藏。
colors(android):指示器颜色,可以多个,循环显示。
progressBackgroundColor(android):指示器背景颜色
size(android):值:[0,1]。指示器大小,默认1,0:large
progressViewOffset(android):指示器距离顶部的位置,默认0.
tintColor(ios):指示器颜色
title(ios):指示器下显示的文字
titleColor(ios):指示器下显示的文字的颜色
/** * Created by on 2017/5/17. */ import React, {Component} from 'react'; import { StyleSheet, View, Text, ScrollView, RefreshControl, } from 'react-native'; export default class RefreshControlDemo extends Component { static navigationOptions = { title: 'RefreshControl', }; state = { loaded:0, isRefreshing: false, data: Array.from(new Array(20)).map((val, i) => ({text: '初始化: ' + i, clicks: 0})), } _onRefresh = () => { this.setState({isRefreshing: true}); setTimeout(() => { // prepend 10 items const rowData = Array.from(new Array(10)) .map((val, i) => ({ text: '第几次加载: ' + (+this.state.loaded + i), clicks: 0, })) .concat(this.state.data); this.setState({ loaded: this.state.loaded + 10, isRefreshing: false, data: rowData, }); }, 3000); } render() { return ( <ScrollView style={{flex:1}} refreshControl={ <RefreshControl refreshing={this.state.isRefreshing} onRefresh={this._onRefresh} tintColor="#ff0000" title="Loading..." titleColor="#00ff00" size={0} progressViewOffset={30} colors={['#0000ff','#ff0000', '#00ff00', ]} progressBackgroundColor="#ffff00" /> }> <View> { this.state.data.map((row, ii) => { return (<Text>{row.text}</Text>); }) } </View> </ScrollView> ); } }
github下载地址
相关文章推荐
- 【React Native开发】React Native控件之RefreshControl组件详解(21)
- React-Native- RefreshControl && Navigator 使用案例
- react native SegmentedControlIOS 使用详解
- react native ScrollView 使用详解
- react native DatePickerIOS 使用详解
- react-native-router-flux 使用详解(三)
- react native Modal 使用详解
- react native TabBarIOS 使用详解
- React Native - Keyboard API使用详解(监听处理键盘事件)
- React Native之Redux使用详解之Actions(29)
- react-native-router-flux 使用详解(二)
- react native ActivityIndicator使用详解
- react native Alert AlertIOS 使用详解
- 【React Native开发】React Native控件之WebView组件详解以及实例使用(22)
- react native ActionSheetIOS 使用详解
- react native FlatList使用详解以及上拉刷新下拉加载带可运行demo
- RN开源UI组件之react-native-button 使用详解
- react-native-router-flux 使用详解(一)
- react-native-router-flux 使用详解(三)
- react_native_router_flux_使用详解(二)