Skip to content

Commit

Permalink
fix #47
Browse files Browse the repository at this point in the history
  • Loading branch information
spromicky committed Oct 10, 2020
1 parent 4f6c717 commit 3ac3657
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions StepSlider/source/StepSlider/StepSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ - (void)addLayers
_trackLayer = [CAShapeLayer layer];
_sliderCircleLayer = [CAShapeLayer layer];
_sliderCircleLayer.contentsScale = [UIScreen mainScreen].scale;
_sliderCircleLayer.actions = @{@"contents": [NSNull null]};

[self.layer addSublayer:_sliderCircleLayer];
[self.layer addSublayer:_trackLayer];
Expand Down Expand Up @@ -183,17 +184,17 @@ - (void)layoutLayersAnimated:(BOOL)animated
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
}

_sliderCircleLayer.path = NULL;
_sliderCircleLayer.contents = nil;

if (self.sliderCircleImage) {
_sliderCircleLayer.path = NULL;
_sliderCircleLayer.frame = CGRectMake(0.f, 0.f, fmaxf(self.sliderCircleImage.size.width, 44.f), fmaxf(self.sliderCircleImage.size.height, 44.f));
_sliderCircleLayer.contents = (__bridge id)self.sliderCircleImage.CGImage;
_sliderCircleLayer.contentsGravity = kCAGravityCenter;
} else {
CGFloat sliderFrameSide = fmaxf(self.sliderCircleRadius * 2.f, 44.f);
CGRect sliderDrawRect = CGRectMake((sliderFrameSide - sliderDiameter) / 2.f, (sliderFrameSide - sliderDiameter) / 2.f, sliderDiameter, sliderDiameter);

_sliderCircleLayer.contents = nil;
_sliderCircleLayer.frame = CGRectMake(0.f, 0.f, sliderFrameSide, sliderFrameSide);
_sliderCircleLayer.path = [UIBezierPath bezierPathWithRoundedRect:sliderDrawRect cornerRadius:sliderFrameSide / 2].CGPath;
_sliderCircleLayer.fillColor = [self.sliderCircleColor CGColor];
Expand Down Expand Up @@ -249,7 +250,8 @@ - (void)layoutLayersAnimated:(BOOL)animated
trackCircle = _trackCirclesArray[i];
} else {
trackCircle = [CAShapeLayer layer];
trackCircle.actions = @{@"fillColor": [NSNull null]};
trackCircle.actions = @{@"fillColor": [NSNull null],
@"contents": [NSNull null]};

[self.layer addSublayer:trackCircle];

Expand Down

0 comments on commit 3ac3657

Please sign in to comment.