• 源码-0105-Autoresizing


    Autoresizing
    

     代码形式

    //
    //  ViewController.m
    //  05-Autoresizing
    
    #import "ViewController.h"
    
    @interface ViewController ()
    /** 蓝色 */
    @property (nonatomic, strong) UIView *blueView;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        UIView *blueView = [[UIView alloc] init];
        blueView.backgroundColor = [UIColor blueColor];
        blueView.frame = CGRectMake(0, 0, 250, 250);
        [self.view addSubview:blueView];
        self.blueView = blueView;
        
        UIView *redView = [[UIView alloc] init];
        redView.backgroundColor = [UIColor redColor];
        redView.frame = CGRectMake(0, 150, 250, 100);
        redView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
        [blueView addSubview:redView];
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        CGFloat w = 200 + arc4random_uniform(100);
        CGFloat h = 200 + arc4random_uniform(100);
        self.blueView.frame = CGRectMake(0, 0, w, h);
    }
    /**
     UIViewAutoresizingNone                 = 0,
     UIViewAutoresizingFlexibleLeftMargin   = 1 << 0, 距离父控件左边的间距是伸缩的(不固定的)
     UIViewAutoresizingFlexibleRightMargin  = 1 << 2, 距离父控件右边的间距是伸缩的(不固定的)
     UIViewAutoresizingFlexibleTopMargin    = 1 << 3, 距离父控件顶部的间距是伸缩的(不固定的)
     UIViewAutoresizingFlexibleBottomMargin = 1 << 5, 距离父控件底部的间距是伸缩的(不固定的)
     UIViewAutoresizingFlexibleWidth        = 1 << 1, 宽度跟随父控件的宽度进行自动伸缩
     UIViewAutoresizingFlexibleHeight       = 1 << 4, 高度跟随父控件的高度进行自动伸缩
     */
    @end
    本人无商业用途,仅仅是学习做个笔记,特别鸣谢小马哥,学习了IOS,另日语学习内容有需要文本和音频请关注公众号:riyuxuexishuji
  • 相关阅读:
    CentOS下部署Django线上运行环境
    MAC 下安装mysqlclient、Homebrew踩坑记
    kali基本命令(-)
    关于Django出现“__str__ returned non-string (type NoneType)”错误的处理
    deepin升级时出现“E: 无法获得锁 /var/lib/apt/lists/lock
    RCNN训练过程
    Jupyter Notebook中使用虚拟环境
    pytorch(cuda)的安装
    conda的基本操作
    第一周、深度学习概念
  • 原文地址:https://www.cnblogs.com/laugh/p/6413995.html
Copyright © 2020-2023  润新知