Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DLRadioButton/DLRadioButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic) IBInspectable UIColor *iconColor;

/**
* @brief Color of selected icon, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *iconSelectedColor;

/**
* @brief Stroke width of icon, default is iconSize / 9.
*/
Expand Down
9 changes: 8 additions & 1 deletion DLRadioButton/DLRadioButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ - (void)drawButton {

- (UIImage *)drawIconWithSelection:(BOOL)selected {
UIColor *defaulColor = selected ? [self titleColorForState:UIControlStateSelected | UIControlStateHighlighted] : [self titleColorForState:UIControlStateNormal];
UIColor *iconColor = self.iconColor ? self.iconColor : defaulColor;

UIColor *iconColor;
if (selected) {
iconColor = self.iconSelectedColor ? self.iconSelectedColor : defaulColor;
} else {
iconColor = self.iconColor ? self.iconColor : defaulColor;
}

UIColor *indicatorColor = self.indicatorColor ? self.indicatorColor : defaulColor;
CGFloat iconSize = self.iconSize;
CGFloat iconStrokeWidth = self.iconStrokeWidth ? self.iconStrokeWidth : iconSize / 9;
Expand Down