Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

reactjs - React Native adding border to PNG

For some reason React Native is displaying the below left and right border when I run my application on iOS (Android is fine). As you can see on the second image, the logo doesn't have any borders at all.

Do you know where it could be coming from?

export const Logo = styled.Image`
  align-self: center;
`;

<Logo source={require('../../assets/logo.png')} style={{ width: 200, height: 200 }} />

enter image description here enter image description here

question from:https://stackoverflow.com/questions/65829899/react-native-adding-border-to-png

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can add elevation:0 to solve it on Android, and add shadowOffset: { height: 0, width: 0 }, shadowOpacity: 0, shadowRadius: 0 to fix it on IOS, like as follow:

export const Logo = styled.Image`
  align-self: center;
`;

<Logo 
    source={require('../../assets/logo.png')} 
    style={{
        width: 200, 
        height: 200, 
        elevation: 0, 
        shadowOffset: { height: 0, width: 0 }, 
        shadowOpacity: 0, 
        shadowRadius: 0
    }} 
/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...