小编Ruk*_*ala的帖子

React原生iOS中的垂直居中自定义字体

在 Expo 中使用 React Native。在 iOS 中难以将自定义导入的字体居中。Android 渲染没有问题,文本垂直居中完美。使用 iOS 它比中心略高。

(原生字体很好地集中在两个模拟器上 - Android 和 iOS)。

任何想法如何解决?

代码如下:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Font } from 'expo';

export default class  extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isReady: false
    };
  }

  async componentDidMount() {
    await Font.loadAsync({
      'KlavikaBold': require('./KlavikaBold.otf'),
    });
    this.setState({ isReady: true });
  }

  render() {
    if (!this.state.isReady) {
      return <Expo.AppLoading />;
      }
    return (
      <View style={styles.container}> …
Run Code Online (Sandbox Code Playgroud)

css react-native react-native-android react-native-ios

8
推荐指数
2
解决办法
4452
查看次数

反应本机海拔高度和绝对位置

尝试添加elevation(阴影)到View作品中,但是我的第二个View(渲染圆圈)隐藏在属性Viewelevation。如果elevation删除,则圆圈position: 'absolute'可以正常工作。

关于如何使用高度和位置查看绝对值有什么想法吗?

我的代码:

import React, { Component } from 'react';
import { StyleSheet, Text, View, Platform, TouchableOpacity } from 'react-native';
import { Font } from 'expo';


export default class Position extends Component {
  render() {
    return (
      <View style={{ flex: 1, marginTop: 25 }}>
        <View style={{ height: 50, backgroundColor: 'red', elevation: 3}}/>
        <View style={styles.circle}><Text>HELLO</Text></View>  
    </View>
    );
  }
}
const styles = StyleSheet.create({
  circle: {
    position: …
Run Code Online (Sandbox Code Playgroud)

elevation react-native

2
推荐指数
1
解决办法
4873
查看次数