Open nissaba opened 9 years ago
I managed to set the border color and the width by setting the properties of SDSegmentedControl instance
self.segmentedControl.borderColor = [UIColor redColor];
self.segmentedControl.borderWidth = .4;
I have the same issue
// SDSegmentedControl *segmentedControlAppearance = SDSegmentedControl.appearance;
// segmentedControlAppearance.backgroundColor = [UIColor colorWithHexString:PRIMARY_COLOR];
// segmentedControlAppearance.arrowSize = 7;
// segmentedControlAppearance.arrowHeightFactor = 1.0;
SDSegmentView *segmenteViewAppearance = SDSegmentView.appearance;
//[segmenteViewAppearance setTitleFont:[UIFont fontWithName:FONT_LIGHT size:16.0]];
[segmenteViewAppearance setTitleColor:[UIColor colorWithHexString:TEXT_COLOR_2] forState:UIControlStateNormal];
[segmenteViewAppearance setTitleColor:[UIColor colorWithHexString:TEXT_COLOR_1] forState:UIControlStateSelected];
//[segmenteViewAppearance setSelectedTitleFont:[UIFont fontWithName:FONT_LIGHT size:16.0]];
The commented lines are the lines "jump"
This works fine under IOS7 and lower, under IOS8 the first time we push the view containing he SDSegmentControl all is ok. the next time around (Go back to previous view and back to this view) the segmentControl looses appearance setting we push it see below code for the border color and width.
SDSegmentedControl *segmentedControlAppearance = SDSegmentedControl.appearance;
segmentedControlAppearance.backgroundColor = [UIColor colorWithHex:@"#453e34" alpha:alpha];
segmentedControlAppearance.borderColor = [UIColor whiteColor];
segmentedControlAppearance.arrowSize = 10;
segmentedControlAppearance.arrowHeightFactor = 1;
segmentedControlAppearance.arrowPosition = SDSegmentedArrowPositionTop;
segmentedControlAppearance.borderWidth = 1;
we see the black defaults being drawn in black if we are on IOS8 which is inited under commonInits as
The fix I used was to directly set the color to withe and the width to 1 under this init bypassing the usage of the appearance setter.
This was the way I initially was setting in my
viewDidLoad
of the view being pushed as follows- (void)segmentControlInit {
// self.segmentControl.backgroundColor = [UIColor colorWithHex:@"#453e34" alpha:alpha];
SDSegmentedControl *segmentedControlAppearance = SDSegmentedControl.appearance;
segmentedControlAppearance.backgroundColor = [UIColor colorWithHex:@"#453e34" alpha:alpha];
segmentedControlAppearance.borderColor = [UIColor whiteColor];
segmentedControlAppearance.arrowSize = 10;
segmentedControlAppearance.arrowHeightFactor = 1;
segmentedControlAppearance.arrowPosition = SDSegmentedArrowPositionTop;
segmentedControlAppearance.borderWidth = 1;
[segmenteViewAppearance setTitleColor:[UIColor colorWithRed:0.71 green:0.7 blue:0.7 alpha:1] forState:UIControlStateNormal];
[segmenteViewAppearance setTitleColor:[UIColor colorWithHex:@"#70ae47" alpha:1] forState:UIControlStateSelected];
segmenteViewAppearance.titleShadowOffset = CGSizeZero;
stainViewAppearance.backgroundColor = [UIColor clearColor];
stainViewAppearance.shadowColor = [UIColor colorWithHex:@"#453e34" alpha:1];
stainViewAppearance.shadowBlur = 0;
stainViewAppearance.shadowOffset = CGSizeZero;
}