簡體   English   中英

React Native 上的背景顏色曲線

[英]Curve of backgroundcolor on React Native

我在如何使我的背景顏色成為頂部曲線(標題部分)時遇到問題這是我的設計在此處輸入圖像描述

我的目標是在我的 header 零件上設計這種曲線在此處輸入圖像描述

這是我的代碼

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

這是實現此效果的一種方法: 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