zoukankan      html  css  js  c++  java
  • NSLayout​Constraint

    NSLayout​Constraint:定义了UI属性有参照关系的两个UI元素,一个元素的frame变化时,另一个元素变化的规则;依赖依附于最近的共同父视图,包含参照元素本身。

    首要:确定变化参考物;参考物的尺寸发生变化,系统会自动重新计算。

    /* Create constraints explicitly.  Constraints are of the form "view1.attr1 = view2.attr2 * multiplier + constant" 

     If your equation does not have a second view and attribute, use nil and NSLayoutAttributeNotAnAttribute.

     */

    +(instancetype)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(nullable id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c;

    A constraint defines a relationship between two user interface objects that must be satisfied by the constraint-based layout system. Each constraint is a linear equation with the following format:

    item1.attribute1 = multiplier × item2.attribute2 + constant
    

    In this equation, attribute1 and attribute2 are the variables that Auto Layout can adjust when solving these constraints. The other values are defined when you create the constraint. For example, If you’re defining the relative position of two buttons, you might say “the leading edge of the second button should be 8 points after the trailing edge of the first button.” The linear equation for this relationship is shown below:

     
  • 相关阅读:
    work_7_Boolean和boolean,基本类型和包装类型
    work_06_服务器上传图片错误
    work_05_64未随机id生成器
    work_04_谷歌验证码工具Kaptcha
    vue.js_13_vue的搭建
    每日一java(割草机)
    work_03_常见jq问题处理
    work_02_css样式
    java 27
    java 27
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6651381.html
Copyright © 2011-2022 走看看