zoukankan      html  css  js  c++  java
  • Autolayout(自动布局)

    VFL语言实现以下界面:

     

    - (void)viewDidLoad

    {

        [super viewDidLoad];

        //创建上面的view

        UIView *topView = [[UIView alloc]init];

        topView.backgroundColor = [UIColor redColor];

        [self.view addSubview:topView];

        topView.translatesAutoresizingMaskIntoConstraints = NO;

        //创建下面的view

        UIView *bottomView = [[UIView alloc]init];

        bottomView.backgroundColor = [UIColor blueColor];

        [self.view addSubview:bottomView];

        bottomView.translatesAutoresizingMaskIntoConstraints = NO;

        //利用VFL语言

        //创建约束(垂直方向)

        NSInteger gap = 20;

        NSArray *verticalC = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-gap-[topView(==50)]-gap-[bottomView(==topView)]" options:NSLayoutFormatAlignAllRight metrics:@{@"gap":@(gap)} views:@{@"topView":topView,@"bottomView":bottomView}];

        [self.view addConstraints:verticalC];

        NSArray *herizonTopC = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-gap-[topView]-gap-|" options:NSLayoutFormatAlignAllRight metrics:@{@"gap":@(gap)} views:@{@"topView":topView}];

        [self.view addConstraints:herizonTopC];

        NSLayoutConstraint *contraintBottom = [NSLayoutConstraint constraintWithItem:bottomView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:topView attribute:NSLayoutAttributeWidth multiplier:0.5 constant:0];

        [self.view addConstraint:contraintBottom];

    }

  • 相关阅读:
    ElementUI table标签展开行
    ElementUI-textarea文本域高度自适应设置的方法
    使用elementUI的el-form组件进行查询时,当输入框仅有一项时,回车自动提交表单,浏览器会刷新页面
    tinymce图片上传
    vue富文本编辑器tinymce
    vue引入assets下图片路径找不到问题
    phpstudy 新项目配置
    Git的使用
    laravel 队列的使用
    laravel中redis用法
  • 原文地址:https://www.cnblogs.com/bluceZ/p/3985149.html
Copyright © 2011-2022 走看看