简体   繁体   English

React Native 上的背景颜色曲线

[英]Curve of backgroundcolor on React Native

I am having trouble on how to make my background color to be curve on top (header part) here is my design我在如何使我的背景颜色成为顶部曲线(标题部分)时遇到问题这是我的设计在此处输入图像描述

and i am aiming for this curve design on my header part我的目标是在我的 header 零件上设计这种曲线在此处输入图像描述

here is my code这是我的代码

<View style={{backgroundColor: "#BF3EFF", height: "20%", width: "100%",
     borderbbottom: "50px"}}> 

Here is the one way you can achieve this effect with: Expo Snack这是实现此效果的一种方法: Expo Snack

在此处输入图像描述

import * as React from 'react';
import { Text, View, StyleSheet, Dimensions, Image } from 'react-native';
import Constants from 'expo-constants';
const screen = Dimensions.get('screen');
export default function App() {
  return (
    <View style={styles.container}>
      <View style={styles.banner}>
        <View style={styles.profile}>
          <Image
            source={{ uri: 'https://i.stack.imgur.com/SXxvF.jpg' }}
            style={{width: 100, height: 100, overflow: "hidden"}}
          />
        </View>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    alignItems: 'center',
  },
  banner: {
    backgroundColor: '#BF3EFF',
    height: screen.width * 2,
    width: screen.width * 2,
    borderWidth: 5,
    borderColor: 'orange',
    borderRadius: screen.width,
    position: 'absolute',
    bottom: screen.height - screen.height*0.3,
    alignItems: 'center',
  },
  profile: {
    width: 100,
    height: 100,
    backgroundColor: 'pink',
    position: 'absolute',
    bottom: -50,
    borderRadius: 50,
    borderWidth: 2,
    borderColor: 'white',
    overflow: "hidden"
  },
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM