From 8e4f0308e034a64d3ae85905a27c9a0915cd19ac Mon Sep 17 00:00:00 2001 From: spromicky Date: Wed, 18 Jan 2017 18:35:06 +0200 Subject: [PATCH] Fix draw for slider when it not under `NSLayoutConstraint`. --- StepSlider/source/StepSlider/StepSlider.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/StepSlider/source/StepSlider/StepSlider.m b/StepSlider/source/StepSlider/StepSlider.m index 62d5bd4..f8d20ea 100644 --- a/StepSlider/source/StepSlider/StepSlider.m +++ b/StepSlider/source/StepSlider/StepSlider.m @@ -143,8 +143,14 @@ - (void)layoutLayersAnimated:(BOOL)animated contentSize = CGSizeMake(fmaxf(44.f, self.bounds.size.width), fmaxf(44.f, sliderHeightWithLabels)); if (!CGSizeEqualToSize(self.bounds.size, contentSize)) { - [self invalidateIntrinsicContentSize]; - return; + if (self.constraints.count) { + [self invalidateIntrinsicContentSize]; + return; + } else { + CGRect newFrame = self.frame; + newFrame.size = contentSize; + self.frame = newFrame; + } } CGFloat contentFrameY = (self.bounds.size.height - sliderHeightWithLabels) / 2.f;