diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift index 2a22e79..c502b87 100644 --- a/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift +++ b/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift @@ -34,7 +34,7 @@ final class SegmentioCellWithImageAfterLabel: SegmentioCell { NSLayoutConstraint.activateConstraints(segmentImageViewVerticalConstraint) let contentViewHorizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( - "|-[segmentTitleLabel]-[segmentImageView(labelHeight)]-|", + "|-(>=10)-[segmentTitleLabel]-[segmentImageView(labelHeight)]-|", options: [.AlignAllCenterY], metrics: metrics, views: views) diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift index c135ece..8a81147 100644 --- a/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift +++ b/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift @@ -34,7 +34,7 @@ class SegmentioCellWithImageBeforeLabel: SegmentioCell { NSLayoutConstraint.activateConstraints(segmentImageViewVerticalConstraint) let contentViewHorizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( - "|-[segmentImageView(labelHeight)]-[segmentTitleLabel]-|", + "|-[segmentImageView(labelHeight)]-[segmentTitleLabel]-(>=10)-|", options: [.AlignAllCenterY], metrics: metrics, views: views) diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift index 60fd8d8..ce41916 100644 --- a/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift +++ b/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift @@ -34,10 +34,26 @@ class SegmentioCellWithImageOverLabel: SegmentioCell { NSLayoutConstraint.activateConstraints(segmentImageViewHorizontConstraint) let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( - "|-[segmentTitleLabel]-|", - options: [], + "|-(>=10)-[segmentTitleLabel]-(>=10)-|", + options: [.AlignAllCenterX], metrics: nil, - views: views) + views: [ + "segmentTitleLabel": segmentTitleLabel + ] + ) + + let segmentTitleLabelHorizontalCenterConstraint = + NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .CenterX, + relatedBy: .Equal, + toItem: segmentTitleLabel.superview, + attribute: .CenterX, + multiplier: 1, + constant: 0.0 + ) + + addConstraint(segmentTitleLabelHorizontalCenterConstraint) NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) let contentViewVerticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift index e0d098a..d26e08d 100644 --- a/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift +++ b/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift @@ -34,10 +34,25 @@ class SegmentioCellWithImageUnderLabel: SegmentioCell { NSLayoutConstraint.activateConstraints(segmentImageViewHorizontConstraint) let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( - "|-[segmentTitleLabel]-|", - options: [], + "|-(>=10)-[segmentTitleLabel]-(>=10)-|", + options: [.AlignAllCenterX], metrics: nil, - views: views) + views: [ + "segmentTitleLabel": segmentTitleLabel + ] + ) + let segmentTitleLabelHorizontalCenterConstraint = + NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .CenterX, + relatedBy: .Equal, + toItem: segmentTitleLabel.superview, + attribute: .CenterX, + multiplier: 1, + constant: 0.0 + ) + + addConstraint(segmentTitleLabelHorizontalCenterConstraint) NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) let contentViewVerticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( diff --git a/Segmentio/Source/Cells/SegmentioCellWithLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithLabel.swift index ea49534..8716fa5 100644 --- a/Segmentio/Source/Cells/SegmentioCellWithLabel.swift +++ b/Segmentio/Source/Cells/SegmentioCellWithLabel.swift @@ -20,11 +20,25 @@ final class SegmentioCellWithLabel: SegmentioCell { // main constraints let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( - "|-[segmentTitleLabel]-|", - options: [], + "|-(>=10)-[segmentTitleLabel]-(>=10)-|", + options: [.AlignAllCenterX], metrics: nil, - views: views + views: [ + "segmentTitleLabel": segmentTitleLabel + ] ) + let segmentTitleLabelHorizontalCenterConstraint = + NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .CenterX, + relatedBy: .Equal, + toItem: segmentTitleLabel.superview, + attribute: .CenterX, + multiplier: 1, + constant: 0.0 + ) + + addConstraint(segmentTitleLabelHorizontalCenterConstraint) NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) // custom constraints