這個要根據狀況而定,有時會頗有用的。spa
//左側輸入框右側按鈕按鈕變長有限制最小寬度,保持輸入框與按鈕左側距離,設定按鈕的壓縮性強(即通常不被拉伸)輸入框拉伸性強容易拉伸 [self.Button mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.TextField); make.right.equalTo(contentView).offset(-DWF(25)); make.height.mas_equalTo(36); make.width.mas_greaterThanOrEqualTo(DWF(80)); }]; [self.Button setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; [self.TextField mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(DWF(36)); make.left.equalTo(self.verifyTipLabel); make.top.equalTo(self.verifyTipLabel.mas_bottom).offset(DEVICE_HEIGHT_OF(YDMargin20)); make.right.mas_equalTo(self.Button.mas_left).offset(-DWF(10)); }]; [self.TextField setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];