Skip to content

Commit

Permalink
edited indicator to show a tick instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
wongherlung committed Jun 10, 2016
1 parent ffb3ad5 commit d7a4ffc
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions DLRadioButton/DLRadioButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,19 @@ - (UIImage *)drawIconWithSelection:(BOOL)selected {

// draw indicator
if (selected) {
UIBezierPath* indicatorPath;
CGRect indicatorRect = CGRectMake((iconSize - indicatorSize) / 2, (iconSize - indicatorSize) / 2, indicatorSize, indicatorSize);
if (self.isIconSquare) {
indicatorPath = [UIBezierPath bezierPathWithRect:indicatorRect];
} else {
indicatorPath = [UIBezierPath bezierPathWithOvalInRect:indicatorRect];
}
[indicatorColor setFill];
[indicatorPath fill];
CGContextAddPath(context, indicatorPath.CGPath);
// This part is edited by wongherlung so that the indicator looks like a tick.
CGRect group = CGRectMake(CGRectGetMinX(rect) + 3, CGRectGetMinY(rect) + 3, CGRectGetWidth(rect) - 6, CGRectGetHeight(rect) - 6);
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint: CGPointMake(CGRectGetMinX(group) + 0.27083 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.54167 * CGRectGetHeight(group))];
[bezierPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.41667 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68750 * CGRectGetHeight(group))];
[bezierPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.75000 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.35417 * CGRectGetHeight(group))];
bezierPath.lineCapStyle = kCGLineCapSquare;

[indicatorColor setStroke];
bezierPath.lineWidth = 1.3;
[bezierPath stroke];

CGContextAddPath(context, bezierPath.CGPath);
}

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
Expand Down

0 comments on commit d7a4ffc

Please sign in to comment.