Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added public property to set step title font #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions RMStepsController/RMStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
*/
@property (nonatomic, strong) NSString *title;

/**
Provides access to the font of the title of this step as it is used by an instance of `RMStepsBar`.
*/
@property (nonatomic, strong) UIFont *titleFont;

/**
Provides access to the font of the number index of this step as it is used by an instance of `RMStepsBar`.
*/
@property (nonatomic, strong) UIFont *numberFont;

/**
Provides access to the selected bar color of this step as it is used by an instance of `RMStepsBar`.
*/
Expand Down Expand Up @@ -67,10 +77,30 @@
*/
@property (nonatomic, strong) UIColor *disabledTextColor;

/**
Provides access to the selected number color of this step as it is used by an instance of `RMStepsBar`.
*/
@property (nonatomic, strong) UIColor *selectedNumberColor;

/**
Provides access to the enabled number color of this step as it is used by an instance of `RMStepsBar`.
*/
@property (nonatomic, strong) UIColor *enabledNumberColor;

/**
Provides access to the disabled number color of this step as it is used by an instance of `RMStepsBar`.
*/
@property (nonatomic, strong) UIColor *disabledNumberColor;

/**
Provides access to the hide or show number label of this step.
*/
@property (nonatomic, assign) BOOL hideNumberLabel;

/**
Provides access to the filled or empty color configuration for the number label of this step.
*/
@property (nonatomic, assign) BOOL fillNumberLabel;


@end
40 changes: 36 additions & 4 deletions RMStepsController/RMStep.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ - (UILabel *)numberLabel {
if(!_numberLabel) {
self.numberLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_numberLabel.text = @"0";
_numberLabel.textColor = self.disabledTextColor;
_numberLabel.textColor = self.disabledNumberColor;
_numberLabel.textAlignment = NSTextAlignmentCenter;
_numberLabel.backgroundColor = [UIColor clearColor];
_numberLabel.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
_numberLabel.font = self.numberFont;
_numberLabel.translatesAutoresizingMaskIntoConstraints = NO;

if (_fillNumberLabel) {
_numberLabel.textColor = [UIColor whiteColor];
}
}

return _numberLabel;
Expand All @@ -96,7 +100,7 @@ - (UILabel *)titleLabel {
_titleLabel.textColor = self.disabledTextColor;
_titleLabel.textAlignment = NSTextAlignmentLeft;
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
_titleLabel.font = self.titleFont;
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
}

Expand All @@ -111,8 +115,12 @@ - (CAShapeLayer *)circleLayer {
_circleLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath;
_circleLayer.position = CGPointMake(9, 10);
_circleLayer.fillColor = [UIColor clearColor].CGColor;
_circleLayer.strokeColor = self.disabledTextColor.CGColor;
_circleLayer.strokeColor = self.disabledNumberColor.CGColor;
_circleLayer.lineWidth = 1;

if (_fillNumberLabel) {
_circleLayer.fillColor = self.disabledNumberColor.CGColor;
}
}

return _circleLayer;
Expand Down Expand Up @@ -174,6 +182,30 @@ - (UIColor *)disabledTextColor {
return _disabledTextColor;
}

- (UIColor *)selectedNumberColor {
if(!_selectedNumberColor) {
self.selectedNumberColor = [UIColor colorWithWhite:1 alpha:1];
}

return _selectedNumberColor;
}

- (UIColor *)enabledNumberColor {
if(!_enabledNumberColor) {
self.enabledNumberColor = [UIColor colorWithWhite:1 alpha:1];
}

return _enabledNumberColor;
}

- (UIColor *)disabledNumberColor {
if(!_disabledNumberColor) {
self.disabledNumberColor = [UIColor colorWithWhite:0.75 alpha:1];
}

return _disabledNumberColor;
}


- (void)setHideNumberLabel:(BOOL)hideNumberLabel {
_hideNumberLabel = hideNumberLabel;
Expand Down
27 changes: 21 additions & 6 deletions RMStepsController/RMStepsBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,14 @@ - (void)updateStepsAnimated:(BOOL)animated {
void (^stepAnimations)(void) = ^(void) {
step.stepView.backgroundColor = step.enabledBarColor;
step.titleLabel.textColor = step.enabledTextColor;
step.numberLabel.textColor = step.enabledTextColor;
step.circleLayer.strokeColor = step.enabledTextColor.CGColor;
step.numberLabel.textColor = step.enabledNumberColor;
step.circleLayer.strokeColor = step.enabledNumberColor.CGColor;
step.hideNumberLabel = NO;

if (step.fillNumberLabel) {
step.numberLabel.textColor = [UIColor whiteColor];
step.circleLayer.fillColor = step.enabledNumberColor.CGColor;
}
};

if(animated)
Expand All @@ -412,9 +417,14 @@ - (void)updateStepsAnimated:(BOOL)animated {
void (^stepAnimations)(void) = ^(void) {
step.stepView.backgroundColor = step.selectedBarColor;
step.titleLabel.textColor = step.selectedTextColor;
step.numberLabel.textColor = step.selectedTextColor;
step.circleLayer.strokeColor = step.selectedTextColor.CGColor;
step.numberLabel.textColor = step.selectedNumberColor;
step.circleLayer.strokeColor = step.selectedNumberColor.CGColor;
step.hideNumberLabel = self.hideNumberLabelWhenActiveStep;

if (step.fillNumberLabel) {
step.numberLabel.textColor = [UIColor whiteColor];
step.circleLayer.fillColor = step.selectedNumberColor.CGColor;
}
};

if(animated)
Expand All @@ -428,9 +438,14 @@ - (void)updateStepsAnimated:(BOOL)animated {
void (^stepAnimations)(void) = ^(void) {
step.stepView.backgroundColor = step.disabledBarColor;
step.titleLabel.textColor = step.disabledTextColor;
step.numberLabel.textColor = step.disabledTextColor;
step.circleLayer.strokeColor = step.disabledTextColor.CGColor;
step.numberLabel.textColor = step.disabledNumberColor;
step.circleLayer.strokeColor = step.disabledNumberColor.CGColor;
step.hideNumberLabel = NO;

if (step.fillNumberLabel) {
step.numberLabel.textColor = [UIColor whiteColor];
step.circleLayer.fillColor = step.disabledNumberColor.CGColor;
}
};

if(animated)
Expand Down