• ios中屏幕适配


    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        // 左上角
        // 固定左边和上边,伸缩右边和下边
        self.leftTop.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        
        // 左下角
        // 固定左边和下边,伸缩右边和上边
        self.leftBottom.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        
        // 右上角
        // 固定右边和上边,伸缩左边和下边
        self.rightTop.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        
        // 右下角
        // 固定右边和下边,伸缩左边和上边
        self.rightBottom.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    }
    关于ios的控件的AutoresizingMask属性  
     个人测试的一些结果
     
    setAutoresizingMask控件的自适应
     
     
        UIViewAutoresizingNone                 = 0,
        UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
        UIViewAutoresizingFlexibleWidth        = 1 << 1,
        UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
        UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
        UIViewAutoresizingFlexibleHeight       = 1 << 4,
        UIViewAutoresizingFlexibleBottomMargin = 1 << 5
    
    UIViewAutoresizingNone
    
     
    UILabel*    label = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 40)];
     
    [label setAutoresizingMask: UIViewAutoresizingNone];  控件相对于俯视图坐标值不变   
     
    CGRectMake(50, 100, 200, 40)
    
    UIViewAutoresizingFlexibleWidth:控件的宽度随着父视图的宽度按比例改变    例如
    
    label宽度为 100     屏幕的宽度为320          当屏幕宽度为480时      label宽度  变为  100*480/320
    同理  
    UIViewAutoresizingFlexibleHeight相同
    
    
    UIViewAutoresizingFlexibleLeftMargin  到屏幕左边的距离随着父视图的宽度按比例改变  
    
    例如    
    CGRectMake(50, 100, 200, 40)];   
    50     屏幕的宽度为320          当屏幕宽度为480时      label宽度  变为  50*480/320
    控件变为    
    CGRectMake(75, 100, 200, 40)];  
    
    UIViewAutoresizingFlexibleRightMargin
    UIViewAutoresizingFlexibleTopMargin
    UIViewAutoresizingFlexibleBottomMargin
  • 相关阅读:
    随机抽样一致性算法(RANSAC)
    RANSAC算法详解
    添加“返回顶部”小图标按钮的JS(JavaScript)代码详解
    vue-cli3组件嵌套
    vue-cli3文件的引入
    vue-cli3组件的使用
    vue ui 使用图形化界面
    vue-cli3及以上版本安装及创建项目
    NetTerm共享文件
    Gin框架配置静态文件static
  • 原文地址:https://www.cnblogs.com/gcb999/p/3212015.html
Copyright © 2020-2023  润新知