Skip to content

Commit 53cc63b

Browse files
committed
Makes some properties customizable via UIAppearance.
1 parent ca1ae50 commit 53cc63b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

HMSegmentedControl/HMSegmentedControl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,35 +72,35 @@ typedef enum {
7272
/**
7373
Text attributes to apply to item title text.
7474
*/
75-
@property (nonatomic, strong) NSDictionary *titleTextAttributes;
75+
@property (nonatomic, strong) NSDictionary *titleTextAttributes UI_APPEARANCE_SELECTOR;
7676

7777
/*
7878
Text attributes to apply to selected item title text.
7979
8080
Attributes not set in this dictionary are inherited from `titleTextAttributes`.
8181
*/
82-
@property (nonatomic, strong) NSDictionary *selectedTitleTextAttributes;
82+
@property (nonatomic, strong) NSDictionary *selectedTitleTextAttributes UI_APPEARANCE_SELECTOR;
8383

8484
/**
8585
Segmented control background color.
8686
8787
Default is `[UIColor whiteColor]`
8888
*/
89-
@property (nonatomic, strong) UIColor *backgroundColor;
89+
@property (nonatomic, strong) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
9090

9191
/**
9292
Color for the selection indicator stripe/box
9393
9494
Default is `R:52, G:181, B:229`
9595
*/
96-
@property (nonatomic, strong) UIColor *selectionIndicatorColor;
96+
@property (nonatomic, strong) UIColor *selectionIndicatorColor UI_APPEARANCE_SELECTOR;
9797

9898
/**
99-
Color for the selection indicator stripe/box
99+
Color for the vertical divider between segments.
100100
101101
Default is `[UIColor blackColor]`
102102
*/
103-
@property (nonatomic, strong) UIColor *verticalDividerColor;
103+
@property (nonatomic, strong) UIColor *verticalDividerColor UI_APPEARANCE_SELECTOR;
104104

105105
/**
106106
Opacity for the seletion indicator box.

HMSegmentedControl/HMSegmentedControl.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ - (void)commonInit {
130130
self.scrollView.showsHorizontalScrollIndicator = NO;
131131
[self addSubview:self.scrollView];
132132

133-
self.backgroundColor = [UIColor whiteColor];
133+
_backgroundColor = [UIColor whiteColor];
134134
self.opaque = NO;
135-
self.selectionIndicatorColor = [UIColor colorWithRed:52.0f/255.0f green:181.0f/255.0f blue:229.0f/255.0f alpha:1.0f];
135+
_selectionIndicatorColor = [UIColor colorWithRed:52.0f/255.0f green:181.0f/255.0f blue:229.0f/255.0f alpha:1.0f];
136136

137137
self.selectedSegmentIndex = 0;
138138
self.segmentEdgeInset = UIEdgeInsetsMake(0, 5, 0, 5);
@@ -146,7 +146,7 @@ - (void)commonInit {
146146
self.verticalDividerEnabled = NO;
147147
self.type = HMSegmentedControlTypeText;
148148
self.verticalDividerWidth = 1.0f;
149-
self.verticalDividerColor = [UIColor blackColor];
149+
_verticalDividerColor = [UIColor blackColor];
150150
self.borderColor = [UIColor blackColor];
151151
self.borderWidth = 1.0f;
152152

HMSegmentedControlExample/HMSegmentedControlExample/ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ - (void)viewDidLoad {
4545
segmentedControl1.verticalDividerColor = [UIColor blackColor];
4646
segmentedControl1.verticalDividerWidth = 1.0f;
4747
[segmentedControl1 setTitleFormatter:^NSAttributedString *(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected) {
48-
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName : [UIColor orangeColor]}];
48+
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName : [UIColor blueColor]}];
4949
return attString;
5050
}];
5151
[segmentedControl1 addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];

0 commit comments

Comments
 (0)