Skip to content

Commit

Permalink
Add ability to customize corner radius of the lines for the BEMBoxTyp…
Browse files Browse the repository at this point in the history
…eSquare box type
  • Loading branch information
morozkin committed Mar 5, 2017
1 parent 0b10b0c commit ea7812b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Classes/BEMCheckBox.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ typedef NS_ENUM(NSInteger, BEMAnimationType) {
*/
@property (nonatomic) IBInspectable CGFloat lineWidth;

/** The corner radius which is applied to the box when the boxType is BEMBoxTypeSquare. Default to 3.0.
*/
@property (nonatomic) IBInspectable CGFloat cornerRadius;

/** The duration in seconds of the animation when the check box switches from on and off. Default to 0.5.
*/
@property (nonatomic) IBInspectable CGFloat animationDuration;
Expand Down
8 changes: 8 additions & 0 deletions Classes/BEMCheckBox.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ - (void)commonInit {
_onCheckColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
_tintColor = [UIColor lightGrayColor];
_lineWidth = 2.0;
_cornerRadius = 3.0;
_animationDuration = 0.5;
_minimumTouchSize = CGSizeMake(44, 44);
_onAnimationType = BEMAnimationTypeStroke;
Expand All @@ -87,6 +88,7 @@ - (void)commonInit {
- (void)initPathManager {
_pathManager = [BEMPathManager new];
_pathManager.lineWidth = _lineWidth;
_pathManager.cornerRadius = _cornerRadius;
_pathManager.boxType = _boxType;
}

Expand Down Expand Up @@ -167,6 +169,12 @@ - (void)setLineWidth:(CGFloat)lineWidth {
[self reload];
}

- (void)setCornerRadius:(CGFloat)cornerRadius {
_cornerRadius = cornerRadius;
_pathManager.cornerRadius = cornerRadius;
[self reload];
}

- (void)setOffAnimationType:(BEMAnimationType)offAnimationType {
_offAnimationType = offAnimationType;
}
Expand Down
4 changes: 4 additions & 0 deletions Classes/BEMPathManager.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
*/
@property (nonatomic) CGFloat lineWidth;

/** The corner radius of the path when the boxType is BEMBoxTypeSquare.
*/
@property (nonatomic) CGFloat cornerRadius;

/** The type of box.
* Depending on the box type, paths may be created differently
* @see BEMBoxType
Expand Down
2 changes: 1 addition & 1 deletion Classes/BEMPathManager.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (UIBezierPath *)pathForBox {
UIBezierPath* path;
switch (self.boxType) {
case BEMBoxTypeSquare:
path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.size, self.size) cornerRadius:3.0];
path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.size, self.size) cornerRadius:self.cornerRadius];
[path applyTransform:CGAffineTransformRotate(CGAffineTransformIdentity, M_PI * 2.5)];
[path applyTransform:CGAffineTransformMakeTranslation(self.size, 0)];
break;
Expand Down

0 comments on commit ea7812b

Please sign in to comment.