1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| 获取屏幕尺寸 const window = Dimensions.get('window'); const screenHeight = Platform.OS === 'ios' ? window.height : window.height - StatusBar.currentHeight; const screenWidth = window.width;
在代码中动态获取View的尺寸 ref={(ref) => this.buttonRef = ref} UIManager.measure(findNodeHandle(this.buttonRef), (x, y, width, height, pageX, pageY) => { console.log('width:::::' + width); this.setState({ popWidth: width, });
}); Dimensions, StatusBar, UIManager, findNodeHandle 都是'react-native'的导入
|