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
// Init border bottom layer
[self.layer addSublayer:_borderBottomLayer = CAShapeLayer.layer];
if (!SD_IS_IOS7) {
self.borderColor = UIColor.whiteColor;
self.borderWidth = .5;
} else {
self.borderColor = UIColor.blackColor;
self.borderWidth = .25;
}
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;
SDSegmentView *segmenteViewAppearance = SDSegmentView.appearance;`
[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;
`SDStainView *stainViewAppearance = SDStainView.appearance;`
stainViewAppearance.backgroundColor = [UIColor clearColor];
stainViewAppearance.shadowColor = [UIColor colorWithHex:@"#453e34" alpha:1];
stainViewAppearance.shadowBlur = 0;
stainViewAppearance.shadowOffset = CGSizeZero;
}