zoukankan      html  css  js  c++  java
  • 代码控制Autolayout

    -(void)setupView{
        // 代码方式实现自动布局 VFL
        // 创建一个Tableview;
        UITableView *tableView = [[UITableView alloc] init];
        //tableView.backgroundColor = [UIColor redColor];
        tableView.delegate = self;
    #warning 代码实现自动布局,要设置下面的属性为NO
        tableView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:tableView];
        self.tableView = tableView;
        
        // 创建输入框View
        WCInputView *inputView = [WCInputView inputView];
        inputView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:inputView];
        
        // 自动布局
        
        // 水平方向的约束
       NSDictionary *views = @{@"tableview":tableView,
                                @"inputView":inputView};
        
        // 1.tabview水平方向的约束
        NSArray *tabviewHConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[tableview]-0-|" options:0 metrics:nil views:views];
        [self.view addConstraints:tabviewHConstraints];
        
        // 2.inputView水平方向的约束
        NSArray *inputViewHConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[inputView]-0-|" options:0 metrics:nil views:views];
        [self.view addConstraints:inputViewHConstraints];
        
        
        // 垂直方向的约束
        NSArray *vContraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-64-[tableview]-0-[inputView(50)]-0-|" options:0 metrics:nil views:views];
        [self.view addConstraints:vContraints];
        self.inputViewConstraint = [vContraints lastObject];
        NSLog(@"%@",vContraints);
    }
    IOS开发
  • 相关阅读:
    Transaction 'IREG', Abend 'APCT', at '????'.
    CICS中设置是否具有可修改性
    常用命令总结
    常用语句总结
    _func_
    数组排序返回索引-python和c++的实现
    数组的并行求和-cuda实现
    Pytorch 多GPU训练-多计算节点并行-All you need
    Pytorch 多GPU训练-单运算节点-All you need
    Windows 编程中的问题
  • 原文地址:https://www.cnblogs.com/luanmage/p/4585469.html
Copyright © 2011-2022 走看看