【发布时间】:2019-04-04 19:53:58
【问题描述】:
我提供了一个 ImageBackground 组件,我希望它占据整个屏幕,但即使我调整图像大小两次或更多,它似乎也有小填充。它来自哪里?
Here is the code of the component
import React from "react";
import { View, Text, Button, ImageBackground, StyleSheet } from "react-
native";
export class HomeScreen extends React.Component {
static navigationOptions = {
//To hide the NavigationBar from current Screen
header: null
};
render() {
return (
<ImageBackground source={require('../imgs/bgx.png')} style={
styles.container }>
</ImageBackground>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'stretch',
resizeMode: 'stretch'
}
});
【问题讨论】:
-
兄弟,那张图好大啊……
-
确保您的原始图片适合 iOS 设备的宽高比,然后特别确保它是 24 BPP(不透明),这意味着图片中没有 Alpha 通道。
-
看来是这个原因!我已经尝试过另一个图像,它非常适合!谢谢!!
标签: ios react-native imagebackground