Skip to content

Commit

Permalink
Merge pull request Boris-Em#10 from Boris-Em/bug/9-ChangeColor
Browse files Browse the repository at this point in the history
Bug/9 change color
  • Loading branch information
Boris-Em committed Nov 21, 2015
2 parents dc75191 + 6d68f57 commit 6169686
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
22 changes: 22 additions & 0 deletions Classes/BEMCheckBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,39 @@ - (void)setAnimationDuration:(CGFloat)animationDuration {
- (void)setBoxType:(BEMBoxType)boxType {
_boxType = boxType;
_pathManager.boxType = boxType;
[self reload];
}

- (void)setLineWidth:(CGFloat)lineWidth {
_lineWidth = lineWidth;
_pathManager.lineWidth = lineWidth;
[self reload];
}

- (void)setOffAnimationType:(BEMAnimationType)offAnimationType {
_offAnimationType = offAnimationType;
}

- (void)setTintColor:(UIColor *)tintColor {
_tintColor = tintColor;
[self drawOffBox];
}

- (void)setOnTintColor:(UIColor *)onTintColor {
_onTintColor = onTintColor;
[self reload];
}

- (void)setOnFillColor:(UIColor *)onFillColor {
_onFillColor = onFillColor;
[self reload];
}

- (void)setOnCheckColor:(UIColor *)onCheckColor {
_onCheckColor = onCheckColor;
[self reload];
}

#pragma mark Gesture Recognizer
- (void)handleTapCheckBox:(UITapGestureRecognizer *)recognizer {
[self setOn:!self.on animated:YES];
Expand Down
5 changes: 0 additions & 5 deletions Sample Project/CheckBox/BEMMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ - (void)didReceiveMemoryWarning {
#pragma mark Actions
- (IBAction)didDragLineWidthSlider:(UISlider *)slider {
self.checkBox.lineWidth = slider.value;
[self.checkBox reload];
}

- (IBAction)didDragAnimationSpeedSlider:(UISlider *)slider {
Expand All @@ -52,8 +51,6 @@ - (IBAction)didDragAnimationSpeedSlider:(UISlider *)slider {

- (IBAction)didTapOnBoxTypeSegmentedControl:(UISegmentedControl *)segmentedControl {
self.checkBox.boxType = (segmentedControl.selectedSegmentIndex == 0) ?BEMBoxTypeCircle : BEMBoxTypeSquare;

[self.checkBox reload];
}

- (IBAction)didTapOnDrawTypeSegmentedControl:(UISegmentedControl *)segmentedControl {
Expand All @@ -63,15 +60,13 @@ - (IBAction)didTapOnDrawTypeSegmentedControl:(UISegmentedControl *)segmentedCont
self.checkBox.onTintColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
self.checkBox.onFillColor = [UIColor clearColor];
self.checkBox.onCheckColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
[self.checkBox reload];
break;

default:
self.checkBox.tintColor = [UIColor lightGrayColor];
self.checkBox.onTintColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
self.checkBox.onFillColor = [UIColor colorWithRed:0 green:122.0/255.0 blue:255/255 alpha:1];
self.checkBox.onCheckColor = [UIColor whiteColor];
[self.checkBox reload];
break;
}
}
Expand Down
18 changes: 6 additions & 12 deletions Sample Project/CheckBoxTests/CheckBoxTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,13 @@ - (void)testOn {

- (void)testReload {
self.checkBox.on = NO;
self.checkBox.lineWidth = 5.0;
CAShapeLayer *offLayer = (CAShapeLayer *)[self.checkBox.layer.sublayers firstObject];
XCTAssertNotNil(offLayer);
XCTAssert(offLayer.lineWidth == 2.0);
XCTAssert(self.checkBox.layer.sublayers.count == 1);

XCTAssert(self.checkBox.on == NO);
[self.checkBox reload];
self.checkBox.on = NO;

offLayer = (CAShapeLayer *)[self.checkBox.layer.sublayers firstObject];
XCTAssertNotNil(offLayer);
XCTAssert(offLayer.lineWidth == 5.0);
XCTAssert(self.checkBox.layer.sublayers.count == 1);
XCTAssert(self.checkBox.on == NO);
self.checkBox.on = YES;
XCTAssert(self.checkBox.on == YES);
[self.checkBox reload];
XCTAssert(self.checkBox.on == YES);
}

@end

0 comments on commit 6169686

Please sign in to comment.