【发布时间】:2019-01-10 13:53:47
【问题描述】:
所以,我在 react native 中有一个模式,它占据了我的整个屏幕,我不希望这种情况发生,任何想法如何配置它? 我有以下结构
<Modal visible={props.display} animationType="slide" style={{
width: '50%',
height: '50%'}}>
<Wrapper>
<ShiftDeclinedWrapper>
<CenterText padding="20px">{props.data}</CenterText>
<Footer>
<ButtonWrapper>
<Button
isDisabled={props.isLoading}
onPress={() => props.declineAccept()}
textColor="white"
color={theme.color.red}>
Decline
</Button>
</ButtonWrapper>
<ButtonWrapper>
<Button
isDisabled={props.isLoading}
onPress={props.declineBack}
textColor="white"
color={theme.color.green}>
No, thanks
</Button>
</ButtonWrapper>
</Footer>
</ShiftDeclinedWrapper>
</Wrapper>
</Modal>
Wrapper组件结构是
export const Wrapper = styled.View`
display: flex;
align-items: center;
justify-content: center;
flex-direction: row;
flex: 1;
`;
ShiftDeclineWrapper 只是
export const ShiftDeclinedWrapper = styled.View`
text-align: center;
`;
我尝试将 50% 的宽度/高度设置为确保它可以正常工作,以便我可以按照自己的意愿设置样式,我尝试将它放在 modal、wrapper 和 shiftdeclinewrapper 上,也没有任何效果
【问题讨论】:
-
我推荐使用 react-native-modal 而不是标准的 Modal
标签: javascript reactjs react-native