zoukankan      html  css  js  c++  java
  • Masonry 原理与使用说明

    原理:

    1)约束生成;MASConstraintMaker;

    2)缺省补齐:

    - (void)setSecondViewAttribute:(id)secondViewAttribute {

        if ([secondViewAttribute isKindOfClass:NSValue.class]) {

            [self setLayoutConstantWithValue:secondViewAttribute];

        } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {

            _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];

        } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {

            _secondViewAttribute = secondViewAttribute;

        } else {

            NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);

        }

    }

    3)寻找约束添加视图,并添加

        if (self.secondViewAttribute.view) {

            MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];

            NSAssert(closestCommonSuperview,

                     @"couldn't find a common superview for %@ and %@",

                     self.firstViewAttribute.view, self.secondViewAttribute.view);

            self.installedView = closestCommonSuperview;

        } else if (self.firstViewAttribute.isSizeAttribute) {

            self.installedView = self.firstViewAttribute.view;

        } else {

            self.installedView = self.firstViewAttribute.view.superview;

        }

    4)

    (1)绝对尺寸信息添加到自身;

    (2)绝对布局数据添加到父视图;

    (3)参考系属性缺失补全为目标属性。

  • 相关阅读:
    多线程环境下调用 HttpWebRequest 并发连接限制
    i—比 i++ 快?
    文件在不同文件系统间拷贝文件时间改变的问题
    Go websocket 聊天室demo2
    Go websocket 聊天室demo以及k8s 部署
    AcWing 1077. 皇宫看守
    AcWing 1073. 树的中心
    AcWing 1085. 不要62
    AcWing 1081 度的数量
    AcWing 1082. 数字游戏
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7929779.html
Copyright © 2011-2022 走看看