diff --git a/SWTableViewCell/PodFiles/SWTableViewCell.m b/SWTableViewCell/PodFiles/SWTableViewCell.m index 3daceac..87d3dab 100644 --- a/SWTableViewCell/PodFiles/SWTableViewCell.m +++ b/SWTableViewCell/PodFiles/SWTableViewCell.m @@ -166,14 +166,22 @@ - (void)initializer ]]; [clipView addSubview:buttonView]; + + // Constrain the maximum button width so that at least a button's worth of contentView is left visible. (The button view will shrink accordingly.) + NSLayoutConstraint* maximumButtonWidth; + maximumButtonWidth = [NSLayoutConstraint constraintWithItem:buttonView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationLessThanOrEqual + toItem:self.contentView + attribute:NSLayoutAttributeWidth multiplier:1.0 + constant:-kUtilityButtonWidthDefault]; + maximumButtonWidth.priority = 750.0f;//Fix to https://github.com/CEWendel/SWTableViewCell/issues/233 [self addConstraints:@[ // Pin the button view to the appropriate outer edges of its clipping view. [NSLayoutConstraint constraintWithItem:buttonView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:clipView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:buttonView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:clipView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:buttonView attribute:alignmentAttribute relatedBy:NSLayoutRelationEqual toItem:clipView attribute:alignmentAttribute multiplier:1.0 constant:0.0], - - // Constrain the maximum button width so that at least a button's worth of contentView is left visible. (The button view will shrink accordingly.) - [NSLayoutConstraint constraintWithItem:buttonView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationLessThanOrEqual toItem:self.contentView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-kUtilityButtonWidthDefault], + maximumButtonWidth, ]]; } }