关于segmentControl不同状态不同颜色的设置

关于segmentControl不同状态不同颜色的设置

今天做这样的样式的,时候,发现他的border也会和background重叠在一起,非常不好看,于是我选择重新设置他的border,使得他的颜色不会重叠在一起。做好之后如下效果:

 

关于segmentControl不同状态不同颜色的设置

    [self setBorderAndColor:self.payBuddySegmentControl];

-(void)setBorderAndColor:(UIView *)bgView{

    

    bgView.layer.cornerRadius = kButtonCornerRadius;

    bgView.clipsToBounds = YES;

    //border

    bgView.layer.borderWidth = 1.0f;

    bgView.layer.borderColor = [UIColor whiteColor].CGColor;

}