Skip to content

Commit

Permalink
Merge pull request youknowone#143 from iDay/master
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
youknowone committed Jan 10, 2014
2 parents 90700e0 + 66bfcd2 commit 9216f36
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions UI7Kit/UI7SegmentedControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ - (void)_tintColorUpdated {
[self setBackgroundImage:highlightedBackgroundImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
[self setBackgroundImage:selectedBackgroundImage forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

[self setDividerImage:tintColor.image forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
if (tintColor != [UIColor clearColor]) {//use setted dividerImage
[self setDividerImage:tintColor.image forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}

self.layer.borderColor = tintColor.CGColor;
}
Expand All @@ -113,7 +115,11 @@ - (void)_backgroundColorUpdated {
if ([self titleTextAttributesForState:UIControlStateSelected]) { //if i customize a new style, no need to update this.
return;
}
NSDictionary *selectedAttributes = @{UITextAttributeTextColor: self.stackedBackgroundColor};
// NSDictionary *selectedAttributes = @{UITextAttributeTextColor: self.stackedBackgroundColor};
UIColor *tintColor = self.tintColor;
UIColor *whiteColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f];
NSDictionary *selectedAttributes = @{UITextAttributeTextColor: [tintColor isEqual:whiteColor] ? [UIColor darkTextColor] : self.stackedBackgroundColor};//if tintColor is white, then set selectedColor to darkTextColor

[self setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
}

Expand Down

0 comments on commit 9216f36

Please sign in to comment.