首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在react native中设计半圆/椭圆?

问如何在react native中设计半圆/椭圆?
EN

Stack Overflow用户
提问于 2020-07-02 19:51:31
回答 1查看 1.3K关注 0票数 0

我是react原生的新手。我正在设计UI,我想在其中设计半圆形或椭圆形。我试过了,但输出不符合预期。我们可以在react原生中使用canvas或svg吗?

实际:

​

​

当前:

​

​

Code.js

代码语言:javascript
复制
     <View style={{ flex: 1, flexDirection: 'row' }}>    
          <View style={styles.circleSkyBlue}></View>
          <View style={styles.circleViolet}></View> 
     </View>

code.css

代码语言:javascript
复制
      circleViolet:{
            width: 239,
            height: 134,
          
            borderBottomRightRadius: 50,
            borderBottomLeftRadius: 100, 
            backgroundColor: '#596AB2',
            transform: [
                {scaleX: 1.2}
                ] 
        },
        circleSkyBlue:{
            width: 180,
            height: 84,               
            borderBottomRightRadius: 100,
            borderBottomLeftRadius: 50,
          
            backgroundColor: '#69C0EC',
            transform: [
                {scaleX: 1}
                ] ,
                overflow: 'hidden', 
        },

任何帮助都是非常感谢的。提前谢谢你

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-02 20:27:43

我已经创建了一个小吃,您可以在其中检查示例。这里不需要使用egg,你可以使用position来获得你想要的UI。

点心:https://snack.expo.io/@ashwith00/ovals

代码:

代码语言:javascript
复制
import * as React from 'react';
import { Text, View, StyleSheet, Dimensions } from 'react-native';
import Constants from 'expo-constants';

const {width} = Dimensions.get('window')

const oval1Width = width * 0.5, oval2Width = width * 0.7;
// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default function App() {
  return (
    <View style={styles.container}>
     <View style={styles.oval1} />
     <View  style={styles.oval2} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  oval1: {
    position: 'absolute',
    width: oval1Width,
    height: oval1Width,
    borderRadius: oval1Width / 2,
    backgroundColor: 'red',
    top: -oval2Width / 3,
    left: -10,
zIndex: 3,
  },
  oval2: {
     position: 'absolute',
    width: oval2Width,
    height: oval2Width,
    borderRadius: oval2Width / 2,
    backgroundColor: 'blue',
    top: -oval2Width / 2.5,
    right: -10,
    zIndex:2
  },
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62695757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档