美文网首页
React Natite实现图片轮播器

React Natite实现图片轮播器

作者: HJXu | 来源:发表于2017-03-22 15:23 被阅读38次

图片轮播器在客户端开发中非常常见,iOS原生开发时候我们可以使用scrollview实现.在跨平台React Native中我们同样可以使用这个组件.不过如果想要更快更高效那我们就可以使用框架:react-native-swiper
具体使用方法:

安装

1,打开终端进入当前项目
2,输入npm install react-native-swiper --save

导入框架

import Swiper from 'react-native-swiper';

具体实现过程

<Swiper
  style={styles.wrapper}
  height={200}//设置高度,不设置默认占满全屏
  showsButtons={false}//是否显示左右箭头
   horizontal={true}//水平还是垂直方向
  autoplay={true}//是否自动循环
  autoplayTimeout={1}//循环间隔
  dot={<View style={{width:8,height:8,backgroundColor:'white',borderRadius:4,marginTop:10,marginLeft:10,marginRight:10}}></View>}//自定义指示点
  activeDot={<View style={{width:8,height:8,backgroundColor:'orange',borderRadius:4,marginTop:10, marginLeft:10,marginRight:10}}></View>}//当前指示点
             >
    <View style={styles.slide1}>
      <Text style={styles.text}>第一页</Text>
    </View>
    <View style={styles.slide2}>
        <Text style={styles.text}>第二页</Text>
     </View>
     <View style={styles.slide3}>
         <Text style={styles.text}>第三页</Text>
      </View>
</Swiper>

样式
wrapper: {
        backgroundColor:'green',
        height:200
    },
    slide1: {
        // flex: 1,
        height: 200,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#9DD6EB',
    },
    slide2: {
        // flex: 1,
        height: 200,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#97CAE5',
    },
    slide3: {
        // flex: 1,
        height: 200,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#92BBD9',
    },
    text: {
        color: '#fff',
        fontSize: 30,
        fontWeight: 'bold',
    }

效果如下

轮播图.png

相关文章

  • React Natite实现图片轮播器

    图片轮播器在客户端开发中非常常见,iOS原生开发时候我们可以使用scrollview实现.在跨平台React Na...

  • React native 图片轮播实现

    图片轮播在APP中经常会遇到,react native有实现图片轮播的库 react-native-swiper使...

  • 关于混编

    常用reactnative 组件 react-native-swiper 图片轮播器 react-native-m...

  • 用react实现的一个轮播图

    最近在写react,实现了一个轮播图功能,才对react组件和状态更多一点的了解。实现的功能是图片自动轮播,当鼠标...

  • 沉浸式渐变图片轮播器

    沉浸式渐变图片轮播器 沉浸式渐变图片轮播器

  • 个人博客—轮播器

    个人博客—轮播器 轮播器自动轮播,每张图片淡入淡出 控制按钮和图片描述跟随图片轮播 鼠标悬停图片上方则停止轮播,滑...

  • 推荐广告位轮播开源库

    1.SDCycleScrollView: UIColloctView实现无限循环图片轮播器(推荐使用)。GitHu...

  • UIScrollView实现图片轮播器

    在很多应用中我们都可以看到图片轮播器,类似于下面的网易新闻,头部图片区域就是一个图片轮播器 这一次我们自己来实现一...

  • iOS 图片轮播器无限滚动的实现

    我们都知道,实现图片轮播器最主要的功能就是如何让图片能够无限轮播,本篇文章就重点讨论一下无限轮播的思路,弱化其他方...

  • 无限轮播器1 - (CollectionView)

    1.数据容器 (轮播器的图片容器) 2.实现CollectionView的UICollectionViewData...

网友评论

      本文标题:React Natite实现图片轮播器

      本文链接:https://www.haomeiwen.com/subject/kzponttx.html