Masnory 约束同行View

2019-06-20 19:16:05 浏览数 (1)

代码语言:javascript复制
    [self.view addSubview:self.labelOne];
    [self.labelOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).with.offset(20);
        make.top.equalTo(self.view.mas_top).with.offset(120);
    }];
    
    [self.view addSubview:self.labelTwo];
    [self.labelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.labelOne.mas_right);
        make.right.equalTo(self.view.mas_right);
        make.top.equalTo(self.view.mas_top).with.offset(120);
        make.height.equalTo(self.labelOne);
    }];
    
    [self.labelOne setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
    /**参数一:(UILayoutPriority)
     UILayoutPriorityRequired
     UILayoutPriorityDefaultHigh
     UILayoutPriorityDefaultLow
     UILayoutPriorityFittingSizeLevel
     */
    
    /**参数二:(UILayoutConstraintAxis)
     UILayoutConstraintAxisHorizontal
     UILayoutConstraintAxisVertical
     */
    [self.labelTwo setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

屏幕快照 2019-06-19 下午7.01.46.png

png

0 人点赞