zoukankan      html  css  js  c++  java
  • iOS原生的布局写法

    方法1:使用 HV方式

    self.backImageView.translatesAutoresizingMaskIntoConstraints = NO;

        [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[backimage]-|" options:NSLayoutFormatAlignmentMask metrics:nil views:@{@"backimage":self.backImageView}]];

         [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[backimage]-|" options:NSLayoutFormatAlignmentMask metrics:nil views:@{@"backimage":self.backImageView}]];

    //直接加

        self.phoneView.translatesAutoresizingMaskIntoConstraints = NO;

        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.phoneView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.logoImage attribute:NSLayoutAttributeBottom multiplier:1.0 constant:33 * FitHeight]];

        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.phoneView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];

        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.phoneView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:230 * FitWidth]];

        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.phoneView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:42 * FitHeight]];

    采用 masorny 的写法

    //电话框

        [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {

           

            make.top.equalTo(self.logoImage.mas_bottom).offset(33 * FitHeight);

            make.centerX.equalTo(self.view.mas_centerX);

            make.width.equalTo(@(230 * FitWidth));

            make.height.equalTo(@(42 * FitHeight));

        }];

  • 相关阅读:
    【python cookbook】【字符串与文本】3.利用shell通配符做字符串匹配
    【python cookbook】【字符串与文本】2.在字符串的开头或结尾处做文本匹配
    python any()和all()用法
    【python cookbook】【字符串与文本】1.针对任意多的分隔符拆分字符串
    python编码:gbk编码与解码
    [转]ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
  • 原文地址:https://www.cnblogs.com/aiyiran/p/5029794.html
Copyright © 2011-2022 走看看