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

Filter by extension

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 @@ -42,6 +42,11 @@ NS_ASSUME_NONNULL_BEGIN
* @brief Color of icon, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *iconColor;

/**
* @brief Background color of icon, default is white color
*/
@property (nonatomic) IBInspectable UIColor *iconBackgroundColor;

/**
* @brief Stroke width of icon, default is iconSize / 9.
Expand Down
6 changes: 6 additions & 0 deletions DLRadioButton/DLRadioButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
static const CGFloat kDefaultIconSize = 15.0;
static const CGFloat kDefaultMarginWidth = 5.0;
static const CFTimeInterval kDefaultAnimationDuration = 0.3;

static NSString * const kGeneratedIconName = @"Generated Icon";

static BOOL _groupModifing = NO;
Expand Down Expand Up @@ -110,6 +111,10 @@ - (UIImage *)drawIconWithSelection:(BOOL)selected {
[iconColor setStroke];
iconPath.lineWidth = iconStrokeWidth;
[iconPath stroke];

[_iconBackgroundColor setFill];
[iconPath fill];

CGContextAddPath(context, iconPath.CGPath);

// draw indicator
Expand Down Expand Up @@ -142,6 +147,7 @@ - (void)initRadioButton {
_iconSize = kDefaultIconSize;
_marginWidth = kDefaultMarginWidth;
_animationDuration = kDefaultAnimationDuration;
_iconBackgroundColor = [UIColor whiteColor];
[super addTarget:self action:@selector(touchUpInside) forControlEvents:UIControlEventTouchUpInside];
}

Expand Down