SVSegmentedControl icon indicating copy to clipboard operation
SVSegmentedControl copied to clipboard

setting a background image in SVSegmentedThumb overlaps the SVSegmentedControl

Open marcomempin opened this issue 12 years ago • 3 comments

Tab Bar

When i set a backgroundImage in self.segmentedControl.thumb, this happens.

marcomempin avatar Jan 16 '13 11:01 marcomempin

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;
    }

marcomempin avatar Jan 16 '13 11:01 marcomempin

Did you try playing around with thumbEdgeInset?

samvermette avatar Jan 18 '13 21:01 samvermette

Also forgot to mention that this is by design so implementations like this one can be made possible:

Screen Shot 2013-02-01 at 6 39 01 PM

samvermette avatar Feb 01 '13 23:02 samvermette