Law*_*euk 8 width react-native
react-native Dimensions.get("window").宽度为iPhone 6s返回375 ....它似乎远非正确.
`
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Dimensions
} from 'react-native';
class AwesomeProject extends Component {
render() {
return <Text style={{margin:50}}>Width: {Dimensions.get("window").width}</Text>;
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);`
Run Code Online (Sandbox Code Playgroud)
Mic*_*vey 19
375是iPhone 6 的分数.对于大多数情况,分数会很好.但是如果你需要像素,你可以使用PixelRatioReact Native提供的API.
例如,要获得iPhone可以使用的渲染像素的距离Dimensions.get('window').width * PixelRatio.get(),iPhone 6的返回值应为750.
| 归档时间: |
|
| 查看次数: |
5979 次 |
| 最近记录: |