Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange thin line on the right side of selected indicator #27

Closed
hiroshihorie opened this issue May 24, 2015 · 5 comments · May be fixed by #34
Closed

Strange thin line on the right side of selected indicator #27

hiroshihorie opened this issue May 24, 2015 · 5 comments · May be fixed by #34

Comments

@hiroshihorie
Copy link

I use the control in titleView, if i push and pop back it goes away but it appears anytime first time.
screencapture 2015-05-25 2 52 27

@nealyoung
Copy link
Owner

Can you post the code you use to set up the control?

@colasbd
Copy link

colasbd commented Jun 17, 2015

I have the same.

It seems to happen when the labels are too long. With the same settings, if I enlarge the NYSegmentedControl then, this strange line disappear.

Here are my settings:

  /*
     SegmentedControl
     */
    // titles
    [self.segmentedControl insertSegmentWithTitle:@"infos"
                                          atIndex:0];
    [self.segmentedControl insertSegmentWithTitle:@"questions"
                                          atIndex:1];
    [self.segmentedControl insertSegmentWithTitle:@"indications"
                                          atIndex:2];
    [self.segmentedControl insertSegmentWithTitle:@"solution"
                                          atIndex:3];

    // actions
    [self.segmentedControl addTarget:self
                              action:@selector(segmentedControlHasBeenTouched:)
                    forControlEvents:UIControlEventValueChanged];


    // setting up
    UIColor * color = [[CBDGlobalInfo colorClusterForExercise:self.exercise] referenceColor] ;

    UIFont * font = [CBDGlobalInfo fontThinWithSize:25] ;


    self.segmentedControl.titleFont = font ;
    self.segmentedControl.titleTextColor =  color;
    self.segmentedControl.selectedTitleFont = font ;
    self.segmentedControl.selectedTitleTextColor = [UIColor whiteColor];


    self.segmentedControl.borderWidth = 0.0f ; //1.0f;
    self.segmentedControl.borderColor = [UIColor clearColor] ; //color ;
    self.segmentedControl.backgroundColor = [UIColor clearColor] ;
    self.segmentedControl.cornerRadius = [CBDGlobalInfo cornerRadius] ;


    self.segmentedControl.drawsGradientBackground = NO;
    self.segmentedControl.drawsSegmentIndicatorGradientBackground = NO;


    self.segmentedControl.segmentIndicatorBackgroundColor = color ;
    self.segmentedControl.segmentIndicatorBorderColor = [UIColor clearColor] ;
    self.segmentedControl.segmentIndicatorBorderWidth = 0.0f ;


    self.segmentedControl.segmentIndicatorInset = 2.0f ; //5.0f ;

@colasbd
Copy link

colasbd commented Aug 19, 2015

@nealyoung
Hi, I have the same issue, and I found a way to fix it. But, it works only because I don't use the gradients.
I don't understand why it is so, but it works. It seems that overriding the draw method is the culprit.

In NYSegmentIndicator.m, you have this method

- (void)drawRect:(CGRect)rect {
    if (self.drawsGradientBackground) {
        CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
        gradientLayer.colors = @[(__bridge id)[self.gradientTopColor CGColor],
                                 (__bridge id)[self.gradientBottomColor CGColor]];
    } else {
        self.layer.backgroundColor = [self.backgroundColor CGColor];
    }
}

If you comment this method, there is no more this line.

@colasbd
Copy link

colasbd commented Sep 15, 2015

@nealyoung

I have new feed back on this.

I have the "strange" line with these settings

    [self.segmentedControl setUpForSegmentColor:color
                                     titleColor:[UIColor blackColor]
                             selectedTitleColor:[UIColor whiteColor]
                                           font:font
                                   cornerRadius:[CBDGlobalInfo cornerRadius]] ;

but it disappears when only changing titleColor to

    [self.segmentedControl setUpForSegmentColor:color
                                     titleColor:color
                             selectedTitleColor:[UIColor whiteColor]
                                           font:font
                                   cornerRadius:[CBDGlobalInfo cornerRadius]] ;

@colasbd
Copy link

colasbd commented Sep 19, 2015

@nealyoung

I have created a toy project that shows the problem.
It is only on the device, not on the simulator.

See: https://github.com/colasjojo/Test-NYSegmentedControl

colasbd added a commit to colasbd/NYSegmentedControl that referenced this issue Sep 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants