I have the problem as below:
I have a View and I just want to set marginTop=20 for each iOS, and I do the following:
<View style={[styles.container,Platform === "ios" ? {marginTop:20}:{marginTop:0}]}>
</View>
But that code is not working. Can someone explain to me why and give me a solution?
CodePudding user response:
You need to write Platform.OS === "ios".
CodePudding user response:
Rewrite the style like this:
<View
style={[
styles.container,
{
marginTop: Platform.OS === "ios" ? 20 : 0
}
]}>
</View>