Jos*_*ran 6 javascript z-index ios react-native
我只有 1 张需要zIndex在前面显示的图像。它适用于 Android,但它不会出现在 IOS 设备中。不知道为什么。
如您所见,用户图像没有出现在 IOS 中。
代码是这样的:
<View>
<Image
source={require("./images/user-img.png")}
style={{width:95,height:95,marginTop:10,marginLeft:135,position:'absolute',zIndex:1}}
/>
<ImageBackground
source={require("./images/bg-img.png")}
style={{ width: "100%", height: "100%"}}>
<View>
//extra code here
</View>
</ImageBackground>
</View>
Run Code Online (Sandbox Code Playgroud)
有谁知道原因吗?
Ken*_* W. 17
请将 zindex 添加到父视图。在 iOS 中,zIndex 不适用于嵌套的 parentView。您需要使 parentView 具有高 zIndex,然后再次定位 View。
<View style={{zIndex: 10}}>
<Image
source={require("./images/user-img.png")}
style={{width:95,height:95,marginTop:10,marginLeft:135,position:'absolute',zIndex:20}}
/>
<ImageBackground
source={require("./images/bg-img.png")}
style={{ width: "100%", height: "100%"}}>
<View>
//extra code here
</View>
</ImageBackground>
Run Code Online (Sandbox Code Playgroud)
小智 0
尝试先渲染背景图像,然后渲染个人资料图像
<View>
<ImageBackground
source={require("./images/bg-img.png")}
style={{ width: "100%", height: "100%"}}>
<View>
//extra code here
</View>
</ImageBackground>
<Image
source={require("./images/user-img.png")}
style={{width:95,height:95,marginTop:10,marginLeft:135,position:'absolute',zIndex:1}}
/>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6790 次 |
| 最近记录: |