[ES6-iOSCode]React Native三方組件之scrollable-tab-view

使用介紹

scrollable-tab-view 是RN的第三方組件,使用的時候我們需要做的是用npm導(dǎo)入到項目的組件管理文件夾下
組件下載地址:
https://github.com/skv-headless/react-native-scrollable-tab-view
安裝方法:

1:終端窗口"cd 項目工程目錄里"
執(zhí)行命令:npm install react-native-scrollable-tab-view --save
 
2:安裝成功后在工程文件里引入:
[ES5語法如下,RN最新的版本已經(jīng)不可以使用]
 var ScrollableTabView = require('react-native-scrollable-tab-view');
[ES6語法如下]
import 組件類命名,{類型,}from '第三方組件名'
import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view';

組件查看:

ls-scrollable-tab-view.png

具體實例代碼:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
   ProgressViewIOS
} from 'react-native';


import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view';
class TabBarView extends Component {
  render() {
    return (
    <ScrollableTabView tabBarUnderlineColor="rgb(23,102,171)" tabBarActiveTextColor="black"  style={{marginTop:20}}>
      <View tabLabel='城市工資排行'>
        <Text style={styles.phoneContainer}>
          城市工資排行
        </Text>
        <ProgressViewIOS style={styles.progressView}  progress={0.3}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="purple" progress={0.2}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="red" progress={0.4}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="orange" progress={0.6}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="yellow" progress={0.8}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="black" progress={0.9}/>
      </View>

      <View tabLabel='行業(yè)工資排行'>
        <Text style={styles.phoneContainer}>
          行業(yè)工資排行
        </Text>
        <ProgressViewIOS style={styles.progressView}  progress={0.3}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="purple" progress={0.2}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="red" progress={0.4}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="orange" progress={0.6}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="yellow" progress={0.8}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="black" progress={0.9}/>
    </View>

      <View tabLabel='職業(yè)工資排行'>
        <Text style={styles.phoneContainer}>
          職業(yè)工資排行
        </Text>
        <ProgressViewIOS style={styles.progressView}  progress={0.3}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="purple" progress={0.2}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="red" progress={0.4}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="orange" progress={0.6}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="yellow" progress={0.8}/>
        <ProgressViewIOS style={styles.progressView} progressTintColor="black" progress={0.9}/>
      </View>

    </ScrollableTabView>

    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  progressView: {
    marginTop: 20,
    marginLeft:10,
    marginRight:10,

  },
  phoneContainer :{
    borderColor:"rgb(241,241,241)",
    backgroundColor:"rgb(255,255,255)",
    flex:1,
    borderStyle:"solid",
    borderWidth:1,
    margin:10,
    borderRadius:3,
    shadowColor: "rgb(229,229,229)",
    shadowOpacity: 0.5,
    shadowRadius: 2,
    shadowOffset: {
      height: 3,
      width: 3
    }
  }
});

AppRegistry.registerComponent('TabBarView', () => TabBarView);

效果圖:

scrollable-tab-view.gif

Demo源碼下載: http://pan.baidu.com/s/1o762aQe 密碼: 87k6

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容