Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris-Em committed Oct 9, 2015
1 parent 5a94af6 commit aa6cc26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Classes/BEMCheckBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

IB_DESIGNABLE

/** Tasteful Checkbox for iOS.
*/
@interface BEMCheckBox : UIView

typedef NS_ENUM(NSInteger, BEMBoxType) {
Expand Down
31 changes: 23 additions & 8 deletions Classes/BEMCheckBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@

@interface BEMCheckBox ()

@property (strong, nonatomic) UITapGestureRecognizer *tap;

/** The layer where the box is drawn when the check box is set to On.
*/
@property (strong, nonatomic) CAShapeLayer *onBoxLayer;

/** The layer where the box is drawn when the check box is set to Off.
*/
@property (strong, nonatomic) CAShapeLayer *offBoxLayer;

/** The layer where the check mark is drawn when the check box is set to On.
*/
@property (strong, nonatomic) CAShapeLayer *checkMarkLayer;

/** The BEMAnimationManager object used to generate animations.
*/
@property (strong, nonatomic) BEMAnimationManager *animationManager;

/** The BEMPathManager object used to generate paths.
*/
@property (strong, nonatomic) BEMPathManager *pathManager;

@end
Expand Down Expand Up @@ -50,11 +61,12 @@ - (void)commonInit {
_animationDuration = 0.5;
_onAnimationType = BEMAnimationTypeStroke;
_offAnimationType = BEMAnimationTypeStroke;
_tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapCheckBox:)];
self.backgroundColor = [UIColor clearColor];

[self initPathManager];
[self initAnimationManager];

[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapCheckBox:)]];
}

- (void)initPathManager {
Expand All @@ -72,8 +84,6 @@ - (void)layoutSubviews {
self.pathManager.size = self.frame.size.height;

[super layoutSubviews];

[self addGestureRecognizer:_tap];
}

- (void)reload {
Expand Down Expand Up @@ -144,7 +154,8 @@ - (void)drawRect:(CGRect)rect {
[self setOn:self.on animated:NO];
}

/// Draws the entire checkbox, depending on the current state of the on property.
/** Draws the entire checkbox, depending on the current state of the on property.
*/
- (void)drawEntireCheckBox {
if (!self.hideBox) {
if (!self.offBoxLayer) {
Expand All @@ -159,7 +170,8 @@ - (void)drawEntireCheckBox {
}
}

/// Draws the box used when the checkbox is set to NO.
/** Draws the box used when the checkbox is set to Off.
*/
- (void)drawOffBox {
[self.offBoxLayer removeFromSuperlayer];
self.offBoxLayer = [CAShapeLayer layer];
Expand All @@ -175,7 +187,8 @@ - (void)drawOffBox {
[self.layer addSublayer:self.offBoxLayer];
}

/// Draws the box when the checkbox is set to YES.
/** Draws the box when the checkbox is set to On.
*/
- (void)drawOnBox {
[self.onBoxLayer removeFromSuperlayer];
self.onBoxLayer = [CAShapeLayer layer];
Expand All @@ -189,6 +202,8 @@ - (void)drawOnBox {
[self.layer addSublayer:self.onBoxLayer];
}

/** Draws the check mark when the checkbox is set to On.
*/
- (void)drawCheckMark {
[self.checkMarkLayer removeFromSuperlayer];
self.checkMarkLayer = [CAShapeLayer layer];
Expand Down
Binary file not shown.

0 comments on commit aa6cc26

Please sign in to comment.