Constrain view to square aspect ratio

I play with the iPhone application interactively, and I would like the view to fill the screen in width and maintain a square aspect ratio. Thus, the height should be equal to the width. I can't seem to find a way to achieve this. Another option is to specify a specific width and height, but I don't see a way to request the width of the device from within native-native to allow me to do this. Any pointers?

+4
source share
1 answer

Hope you are looking for this ...

var Dimensions = require('Dimensions');
var device = Dimensions.get('window');


var styles = StyleSheet.create({
  squareBox: {
    width: device.width,
    height: device.width,
  }
);
+4
source

Source: https://habr.com/ru/post/1619804/


All Articles