Skip to content

Commit ea7812b

Browse files
committed
Add ability to customize corner radius of the lines for the BEMBoxTypeSquare box type
1 parent 0b10b0c commit ea7812b

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Classes/BEMCheckBox.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ typedef NS_ENUM(NSInteger, BEMAnimationType) {
8282
*/
8383
@property (nonatomic) IBInspectable CGFloat lineWidth;
8484

85+
/** The corner radius which is applied to the box when the boxType is BEMBoxTypeSquare. Default to 3.0.
86+
*/
87+
@property (nonatomic) IBInspectable CGFloat cornerRadius;
88+
8589
/** The duration in seconds of the animation when the check box switches from on and off. Default to 0.5.
8690
*/
8791
@property (nonatomic) IBInspectable CGFloat animationDuration;

Classes/BEMCheckBox.m

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ - (void)commonInit {
7272
_onCheckColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
7373
_tintColor = [UIColor lightGrayColor];
7474
_lineWidth = 2.0;
75+
_cornerRadius = 3.0;
7576
_animationDuration = 0.5;
7677
_minimumTouchSize = CGSizeMake(44, 44);
7778
_onAnimationType = BEMAnimationTypeStroke;
@@ -87,6 +88,7 @@ - (void)commonInit {
8788
- (void)initPathManager {
8889
_pathManager = [BEMPathManager new];
8990
_pathManager.lineWidth = _lineWidth;
91+
_pathManager.cornerRadius = _cornerRadius;
9092
_pathManager.boxType = _boxType;
9193
}
9294

@@ -167,6 +169,12 @@ - (void)setLineWidth:(CGFloat)lineWidth {
167169
[self reload];
168170
}
169171

172+
- (void)setCornerRadius:(CGFloat)cornerRadius {
173+
_cornerRadius = cornerRadius;
174+
_pathManager.cornerRadius = cornerRadius;
175+
[self reload];
176+
}
177+
170178
- (void)setOffAnimationType:(BEMAnimationType)offAnimationType {
171179
_offAnimationType = offAnimationType;
172180
}

Classes/BEMPathManager.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
*/
2323
@property (nonatomic) CGFloat lineWidth;
2424

25+
/** The corner radius of the path when the boxType is BEMBoxTypeSquare.
26+
*/
27+
@property (nonatomic) CGFloat cornerRadius;
28+
2529
/** The type of box.
2630
* Depending on the box type, paths may be created differently
2731
* @see BEMBoxType

Classes/BEMPathManager.m

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ - (UIBezierPath *)pathForBox {
1616
UIBezierPath* path;
1717
switch (self.boxType) {
1818
case BEMBoxTypeSquare:
19-
path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.size, self.size) cornerRadius:3.0];
19+
path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.size, self.size) cornerRadius:self.cornerRadius];
2020
[path applyTransform:CGAffineTransformRotate(CGAffineTransformIdentity, M_PI * 2.5)];
2121
[path applyTransform:CGAffineTransformMakeTranslation(self.size, 0)];
2222
break;

0 commit comments

Comments
 (0)