萤石云 iOSSDK,移植跨平台相关工程
JLChen
2021-08-06 edc0f0a0439f9e5a11593e21a4779fa6dbcbe49d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
//  UISegmentedControl+DDKit.m
//  DDCategory
//
//  Created by DeJohn Dong on 15-3-20.
//  Copyright (c) 2015年 DDKit. All rights reserved.
//
 
#import "UISegmentedControl+DDKit.h"
#import "UIImage+DDKit.h"
 
@implementation UISegmentedControl (DDKit)
 
@end
 
@implementation UISegmentedControl (DDFlatten)
 
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED <= 60000)
//处理UISegmentedControl 在iOS6及以下的扁平化效果
- (void)dd_flattenIniOS6 {
    [self dd_flattenIniOS6:nil];
}
 
- (void)dd_flattenIniOS6:(UIColor *)selectedColor {
    if([[UIDevice currentDevice].systemVersion floatValue] < 6.9){
        UIImage *image = [UIImage dd_createImageWithCGSize:CGSizeMake(1, 28) color:self.tintColor];
        [[UISegmentedControl appearance] setBackgroundImage:image
                                                   forState:UIControlStateSelected
                                                 barMetrics:UIBarMetricsDefault];
        [[UISegmentedControl appearance] setDividerImage:image
                                     forLeftSegmentState:UIControlStateNormal
                                       rightSegmentState:UIControlStateSelected
                                              barMetrics:UIBarMetricsDefault];
        
        image = [UIImage dd_createImageWithCGSize:CGSizeMake(1, 28) color:[UIColor clearColor]];
        [[UISegmentedControl appearance] setBackgroundImage:image
                                                   forState:UIControlStateNormal
                                                 barMetrics:UIBarMetricsDefault];
        
        self.layer.borderColor = self.tintColor.CGColor;
        self.layer.borderWidth = 1.0f;
        self.layer.cornerRadius = 4.0f;
        self.layer.masksToBounds = YES;
        
        [[UISegmentedControl appearance] setTitleTextAttributes:@{UITextAttributeTextColor:selectedColor?:[UIColor whiteColor],UITextAttributeFont:[UIFont systemFontOfSize:14],UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetZero]}
                                                       forState:UIControlStateSelected];
        
        [[UISegmentedControl appearance] setTitleTextAttributes:@{UITextAttributeTextColor:self.tintColor?:[UIColor whiteColor],UITextAttributeFont:[UIFont systemFontOfSize:14],UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0, 0)]}
                                                       forState:UIControlStateNormal];
        
    }
}
#endif
@end