美文网首页
2018-12-18 缩放方案

2018-12-18 缩放方案

作者: 056cc6443751 | 来源:发表于2018-12-18 15:38 被阅读0次

    参照别人写的缩放方案试了下

    var React = require('react-native')
    
    var PixelRatio = React.PixelRatio;
    
    const screenWidth = React.Dimensions.get('window').width;
    
    const screenHeight = React.Dimensions.get('window').height;
    
    const fontScale = PixelRatio.getFontScale();
    
    const w = PixelRatio.getPixelSizeForLayoutSize(screenWidth);
    
    const h = PixelRatio.getPixelSizeForLayoutSize(screenHeight);
    
    const DEFAULT_WIDTH = 411;
    
    const DEFAULT_HEIGHT = 683;
    
    const MIN_SCALE = Math.min(screenHeight/DEFAULT_HEIGHT, screenWidth/DEFAULT_WIDTH);
    
    export default class ScreenUtil {
    
    
         static caleHeight(value) {
            return screenHeight/DEFAULT_HEIGHT*value;
        }
    
        static caleHeight2(value) {
            return screenHeight/DEFAULT_HEIGHT*value;
        }
    
        static scaleFontSize(fontSize) {
             return fontSize*MIN_SCALE;
        }
    
        static scaleImageWidth(width) {
            return width*MIN_SCALE;
        }
    
        static scaleImageHeight(height) {
            return height*MIN_SCALE;
        }
    }
    

    相关文章

      网友评论

          本文标题:2018-12-18 缩放方案

          本文链接:https://www.haomeiwen.com/subject/bwdlkqtx.html