Masnory 约束同行View

    [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];
Masnory 约束同行View_第1张图片
屏幕快照 2019-06-19 下午7.01.46.png

你可能感兴趣的:(Masnory 约束同行View)