SDSegmentedControl icon indicating copy to clipboard operation
SDSegmentedControl copied to clipboard

Problem under IOS8 for borderColor and borderWidth

Open nissaba opened this issue 11 years ago • 2 comments

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

nissaba avatar Dec 09 '14 17:12 nissaba

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;

satrun77 avatar Dec 17 '14 07:12 satrun77

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"

ragian avatar Dec 17 '14 23:12 ragian