SVSegmentedControl
SVSegmentedControl copied to clipboard
setting a background image in SVSegmentedThumb overlaps the SVSegmentedControl

When i set a backgroundImage in self.segmentedControl.thumb, this happens.
I looked inside SVSegmentedThumb.m, and by trial and error, i managed to get the "correct" subtrahend for the height of the imageView:
- (UIImageView *)thumbBackgroundImageView {
if(!_thumbBackgroundImageView) {
_thumbBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5+self.segmentedControl.thumbEdgeInset.left,
self.segmentedControl.thumbEdgeInset.top,
self.bounds.size.width-10-self.segmentedControl.thumbEdgeInset.left-self.segmentedControl.thumbEdgeInset.right,
self.backgroundImage.size.height - 3)];
_thumbBackgroundImageView.backgroundColor = [UIColor clearColor];
[self insertSubview:_thumbBackgroundImageView atIndex:0];
self.clipsToBounds = NO;
self.segmentedControl.clipsToBounds = NO;
}
return _thumbBackgroundImageView;
}
Did you try playing around with thumbEdgeInset?
Also forgot to mention that this is by design so implementations like this one can be made possible:
