2017-03-27 66 views

回答

0

您可以顯示一個白色三角形View在圖片上方

import React from 'react'; 
 
import { StyleSheet, View, Image, Dimensions } from 'react-native'; 
 

 
export default class App extends React.Component { 
 
    render() { 
 
    return (
 
     <View style={styles.container}> 
 
     <Image style={styles.img} source={require('./images.jpg')} > 
 
     <View style={[styles.triangle]} /></Image> 
 
     </View> 
 
    ); 
 
    } 
 
} 
 

 
const styles = StyleSheet.create({ 
 
    container: { 
 
    flex: 1, 
 
    backgroundColor: '#fff', 
 
    }, 
 
    triangle: { 
 
    position: 'absolute', 
 
    right: 0, 
 
    bottom: 0, 
 
    width: 0, 
 
    height: 0, 
 
    backgroundColor: 'transparent', 
 
    borderStyle: 'solid', 
 
    borderLeftWidth: Dimensions.get('window').width, 
 
    borderRightWidth: 0, 
 
    borderBottomWidth: 50, 
 
    borderLeftColor: 'transparent', 
 
    borderRightColor: 'transparent', 
 
    borderBottomColor: '#fff', 
 
    }, 
 
    img: { 
 
    width: Dimensions.get('window').width, 
 
    }, 
 
});