zoukankan      html  css  js  c++  java
  • VFL语言

    VFL语言

    • VFL即Visual Format Language,可视化格式语言
    • NSDictionaryOfVariableBindings(testViewA, testViewB):此为一个宏,直接调用,会返回一个key值即为对象名称,键值为对象的字典,如同以下方法一一模一样的字典
    #import "ViewController.h"
    @interface ViewController ()
    @end
    @implementation ViewController
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        UIView *testViewA = [[UIView alloc] init];
        testViewA.backgroundColor = [UIColor blueColor];
        //将testViewA的AutoresizingMask自动转化成约束的属性关闭
        testViewA.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:testViewA];
        
        UIView *testViewB = [[UIView alloc] init];
        testViewB.backgroundColor = [UIColor redColor];
        //将testViewB的AutoresizingMask自动转化成约束的属性关闭
        testViewB.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:testViewB];
        
        //创建参数views字典方式一
        NSDictionary *viewDict1 = @{
                              @"testViewA":testViewA,
                              @"testViewB":testViewB
                              };
        //创建参数metrics字典
        NSDictionary *constant = @{
                                   @"space":@30
                                   };
        //创建水平方向的约束
        NSString *hVFL = @"H:|-space-[testViewA]-space-[testViewB(==testViewA)]-space-|";
        NSArray *hConstrains = [NSLayoutConstraint constraintsWithVisualFormat:hVFL options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom  metrics:constant views:viewDict1];
        [self.view addConstraints:hConstrains];
        
        //创建参数views字典方式二
        NSDictionary *viewDict2 = NSDictionaryOfVariableBindings(testViewA, testViewB);
        //创建垂直方向的约束
        NSString *vVFL = @"V:[testViewA(50)]-space-|";
        NSArray *vConstrains = [NSLayoutConstraint constraintsWithVisualFormat:vVFL options:kNilOptions metrics:constant views:viewDict2];
        [self.view addConstraints:vConstrains];
    
    
    }
    @end
  • 相关阅读:
    IE浏览器和谷歌浏览器相互跳转
    centos7安装docker
    centos7安装groovy
    centos7安装NodeJs
    mongodb数据库的备份还原
    centos7最小版配置
    centos7中python2.7升级到python3.7
    typedef struct用法详解与小结
    MinGW的gdb调试
    MinGW-w64安装教程——著名C/C++编译器GCC的Windows版本
  • 原文地址:https://www.cnblogs.com/igeniuswwh/p/6209139.html
Copyright © 2011-2022 走看看