React Native 圓形進(jìn)度條組件

本文原創(chuàng)首發(fā)于公眾號(hào):ReactNative開發(fā)圈,轉(zhuǎn)載需注明出處。

React Native 圓形進(jìn)度條組件:react-native-circular-progress,圓形的進(jìn)度條組件,支持動(dòng)畫,支持iOS和Android。

演示動(dòng)畫

image.png

安裝方法

npm i --save react-native-circular-progress

IOS需要手動(dòng)Link下ReactART,用Xcode打開項(xiàng)目,添加ART.xcodeproj到Libraries中,然后在Link Binary With Libraries中添加libART.a。如下圖所示:


image.png

使用示例

import { AnimatedCircularProgress } from 'react-native-circular-progress';

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={100}
  tintColor="#00e0ff"
  onAnimationComplete={() => console.log('onAnimationComplete')}
  backgroundColor="#3d5875" />

API說明

  • size – width and height of the circle(圓形的寬度和高度)
  • width - thickness of the lines(圓形線的寬度)
  • backgroundWidth - thickness of the background line(背景線的寬度)
  • fill - current, percentage fill (from 0 to 100)(進(jìn)度值)
  • prefill - percentage fill before the animation (from 0 to 100)(預(yù)先設(shè)置的進(jìn)度值)
  • tintColor - color of a progress line(圓形的線的顏色)
  • backgroundColor - color of a background for progress line. Use 'transparent' to hide(背景線的顏色)
  • rotation - by default, progress starts from the angle = 90?, you can change it by setting value from -360 to 360(旋轉(zhuǎn)度數(shù))
  • tension - the tension value for the spring animation (see here)
  • friction - the friction value for the spring animation (see here)
  • linecap - the shape to be used at the ends of the circle. Possible values: butt (default), round or square. (see here)
  • children(fill) - you can pass function as a child to receive current fill
  • onAnimationComplete - you can pass a callback function that will be invoked when animation is complete. (see here)(動(dòng)畫結(jié)束時(shí)的事件)
  • onLinearAnimationComplete - you can pass a callback function that will be invoked when linear animation is complete. (see here)

特別說明

在react-native 0.50.4版本中,backgroundColor設(shè)置transparent時(shí)會(huì)報(bào)錯(cuò)。暫時(shí)沒找到原因。

完整示例

完整代碼:React Native 圓形進(jìn)度條組件 | forrest23.github.io
本次示例代碼在 Component03文件夾中。

組件地址

GitHub - bgryszko/react-native-circular-progress: React Native component for creating animated, circular progress with ReactART

微信不讓跳轉(zhuǎn)外鏈,可以點(diǎn)擊查看原文來查看外鏈GitHub內(nèi)容。

舉手之勞關(guān)注我的微信公眾號(hào):ReactNative開發(fā)圈

image.png

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,240評(píng)論 0 23
  • afinalAfinal是一個(gè)android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,899評(píng)論 2 45
  • 文|域往 每當(dāng)你拿起專業(yè)課本打算復(fù)習(xí)課程知識(shí)的時(shí)候,你的內(nèi)心是什么感覺呢?很開心?還是很無聊?我相信大部分人都是不...
    域往閱讀 296評(píng)論 0 7
  • 第二章 當(dāng)我從回憶中離開時(shí),門開了,是陳小莫來了。 陳小莫,我最好的朋友,在公司里是我的手下。 “你醒了!怎么樣,...
    茶蘼花開事未了閱讀 236評(píng)論 0 1

友情鏈接更多精彩內(nèi)容