Có thể bạn chỉ cần tạo thành phần chú giải công cụ tùy chỉnh của mình. Dưới đây là một ví dụ rất cơ bản trong làm thế nào để làm cho nó xuất hiện trước mặt các thành phần khác sử dụng một số thủ thuật CSS và tài sản ZIndex: https://codepen.io/vtisnado/pen/WEoGey
class SampleApp extends React.Component {
render() {
return (
/******************* RENDER VISUAL COMPONENTS *******************/
<View style={styles.container}>
<View style={styles.mainView}>
{/* Start: Tooltip */}
<View style={styles.talkBubble}>
<View style={styles.talkBubbleSquare}>
<Text style={styles.talkBubbleMessage}>Put whatever you want here. This is just a test message :)</Text>
</View>
<View style={styles.talkBubbleTriangle} />
</View>
{/* End: Tooltip */}
<View style={styles.anotherView} /> {/* The view with app content behind the tooltip */}
</View>
</View>
/******************* /RENDER VISUAL COMPONENTS *******************/
);
}
}
/******************* CSS STYLES *******************/
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
mainView: {
flex: 1,
flexDirection: 'row',
},
talkBubble: {
backgroundColor: 'transparent',
position: 'absolute',
zIndex: 2, // <- zIndex here
flex: 1,
left: 20,
//left: (Dimensions.get('window').width/2) - 300, // Uncomment this line when test in device.
bottom: 60,
},
talkBubbleSquare: {
width: 300,
height: 120,
backgroundColor: '#2C325D',
borderRadius: 10
},
talkBubbleTriangle: {
position: 'absolute',
bottom: -20,
left: 130,
width: 0,
height: 0,
borderLeftWidth: 20,
borderRightWidth: 20,
borderTopWidth: 20,
borderLeftColor: 'transparent',
borderRightColor: 'transparent',
borderTopColor: '#2C325D',
},
talkBubbleMessage: {
color: '#FFFFFF',
marginTop: 40,
marginLeft: 20,
marginRight: 20,
},
anotherView: {
backgroundColor: '#CCCCCC',
width: 340,
height: 300,
position: 'absolute',
zIndex: 1, // <- zIndex here
},
});
/******************* /CSS STYLES *******************/
CẬP NHẬT: Tôi đã gỡ bỏ widget iframe Codepen vì nó có thể nhầm lẫn một số người dùng, vui lòng theo liên kết ở trên để xem ví dụ.
Vui lòng đưa ra lý do để bỏ phiếu xuống để tôi có thể chỉnh sửa câu hỏi của mình –
Tôi đang sử dụng https://github.com/Jpoliachik/react-native-triangle để vẽ bản vẽ thứ ba mà tôi đã thực hiện theo cách thủ công. Ngoài ra 'phản ứng-native-animatable' để cung cấp cho hình ảnh động – jose920405