如何在iOS中使用zIndex或海拔高度

时间:2019-03-23 16:07:18

标签: react-native react-native-ios react-native-web

我有一个带有react-native-web和expo的Web和ios跨平台应用程序。登录期间有一段时间正在处理,我正在渲染微调器。

微调框仅显示在网络上。


import React from 'react'
import { View, Image, StyleSheet } from 'react-native'
import {
  Headline,
  withTheme,
  type Theme,
  Paragraph,
  ActivityIndicator,
  Colors
} from 'react-native-paper'

import { APP_NAME } from '@src/lib/constants'

type Props = {
    theme: Theme,
}

class Splash extends React.Component<Props> {
  render() {
    return (<View style={styles.container}>
          <Headline style={styles.header}>{ APP_NAME }</Headline>
          {this.props.spinner?
              (<View style={styles.body}>
                  <View style={styles.spinner}>
                      <ActivityIndicator animating={true} color={Colors.grey400} />
                  </View>
                  <View style={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
                    <Image style={{width: 512, height: 512}} source={require('@src/media/123go-big.png')}/>
                  </View>
              </View>):
              (<View style={styles.body}>
                <Paragraph>{ this.props.message || '' }</Paragraph>
                <View style={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
                    <Image style={{width: 256, height: 256}} source={require('@src/media/123go-big.png')}/>
                </View>
              </View>)
          }
      </View>)
  }
}

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,

    paddingVertical: 12
  },
  header: {
    paddingVertical: 36,
    textAlign: 'center'
  },
  body: {
    position: 'fixed',
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,
    zIndex: 0,
    flex: 1,
    flexDirection: 'column',
    paddingVertical: 3,
    paddingHorizontal: 3
  },
  spinner: {
    position: 'fixed',
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,
    backgroundColor: Colors.black,
    justifyContent: 'center',
    alignItems: 'center',
    opacity:0.5,
    zIndex:2
  }
})

export default withTheme(Splash)

0 个答案:

没有答案