reactjs - 从下到上逐渐填充一个圆圈

标签 reactjs react-native

我需要创建一个从下到上逐渐填充的圆形 View (取决于百分比),但我不知道如何实现这个结果。

enter image description here

有什么东西已经存在了吗?我该如何开始呢?

最佳答案

下面是你在 RN 中的做法,还有一个关于零食的演示 - https://snack.expo.io/@noitsnack/circle-fill - super 简单,基本的<View>与造型。如果你想要这个动画,同样容易,让我知道并提出另一个主题,我会在那里发布动画版本。

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


export default class App extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.circle}>
          <View style={[styles.circleFill, { height:'25%' }]} />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
  },
  circle: {
    width: 196,
    height: 196,
    borderRadius: 196 / 2,
    borderWidth: 2,
    borderColor: '#000000',
    overflow: 'hidden',
  },
  circleFill: {
    backgroundColor: 'orange',
    width: '100%',
    bottom: 0,
    position: 'absolute'
  }
});

Android 屏幕截图:

关于reactjs - 从下到上逐渐填充一个圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48853482/

相关文章:

reactjs - [Webpack][React] 在带有代码拆分的 SSR 上,我如何获得页面所需的 block 列表?

reactjs - 如何实现 React Bootstrap 单选按钮

javascript - JS/Reactjs - 访问从顶级函数传递的参数

javascript - React-Native-Web 的视频支持

react-native - 尝试实现 Expo AuthSession 时出现 AuthSession 代理错误

ios - 如何解决 No + [RCTConvert AIR MapCoordinate Array] 错误 : function found. 在 iOS 上 react native map

ReactJS:Material ui 断点

android - React Native yarn android 工作正常,但 ./gradlew assembleRelease 构建在更新compileSdkVersion和targetSdkVersion到31后失败

react-native - route.params 不使用 React Navigation 返回变量

reactjs - React 和 TypeScript 中的 "Object is possibly undefined"