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

Allow use to customize font of Title UILabel and font/color of Bottom UIButton #18

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions THPinViewController/THPinView.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
@property (nonatomic, weak) id<THPinViewDelegate> delegate;
@property (nonatomic, copy) NSString *promptTitle;
@property (nonatomic, strong) UIColor *promptColor;
@property (nonatomic, strong) UIFont *promptFont;
@property (nonatomic, strong) UIFont *bottomButtonFont;
@property (nonatomic, strong) UIColor *bottomButtonColor;
@property (nonatomic, assign) BOOL hideLetters;
@property (nonatomic, assign) BOOL disableCancel;

- (instancetype)initWithDelegate:(id<THPinViewDelegate>)delegate NS_DESIGNATED_INITIALIZER;

- (void)resetInput;

@end
29 changes: 29 additions & 0 deletions THPinViewController/THPinView.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,35 @@ - (void)setPromptColor:(UIColor *)promptColor
self.promptLabel.textColor = promptColor;
}

- (UIFont *)promptFont
{
return self.promptLabel.font;
}

- (void)setPromptFont:(UIFont *)promptFont
{
self.promptLabel.font = promptFont;
}

- (UIFont *)bottomButtonFont
{
return [[self.bottomButton titleLabel] font];
}

- (void)setBottomButtonFont:(UIFont *)bottomButtonFont {
[[self.bottomButton titleLabel] setFont:bottomButtonFont];
}

- (UIColor *)bottomButtonColor
{
return [self.bottomButton tintColor];
}

- (void)setBottomButtonColor:(UIColor *)bottomButtonColor
{
[self.bottomButton setTitleColor:bottomButtonColor forState:UIControlStateNormal];
}

- (BOOL)hideLetters
{
return self.numPadView.hideLetters;
Expand Down
5 changes: 5 additions & 0 deletions THPinViewController/THPinViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ static const NSInteger THPinViewControllerContentViewTag = 14742;
@property (nonatomic, assign) BOOL translucentBackground;
@property (nonatomic, copy) NSString *promptTitle;
@property (nonatomic, strong) UIColor *promptColor;
@property (nonatomic, strong) UIFont *promptFont;
@property (nonatomic, strong) UIFont *bottomButtonFont;
@property (nonatomic, strong) UIColor *bottomButtonColor;
@property (nonatomic, assign) BOOL hideLetters; // hides the letters on the number buttons
@property (nonatomic, assign) BOOL disableCancel; // hides the cancel button

- (instancetype)initWithDelegate:(id<THPinViewControllerDelegate>)delegate NS_DESIGNATED_INITIALIZER;

- (void)resetPinView;

@end
37 changes: 37 additions & 0 deletions THPinViewController/THPinViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ - (void)viewDidLoad
self.pinView.backgroundColor = self.view.backgroundColor;
self.pinView.promptTitle = self.promptTitle;
self.pinView.promptColor = self.promptColor;
self.pinView.promptFont = self.promptFont;
self.pinView.bottomButtonFont = self.bottomButtonFont;
self.pinView.bottomButtonColor = self.bottomButtonColor;
self.pinView.hideLetters = self.hideLetters;
self.pinView.disableCancel = self.disableCancel;
self.pinView.translatesAutoresizingMaskIntoConstraints = NO;
Expand All @@ -75,6 +78,13 @@ - (void)viewDidLoad
multiplier:1.0f constant:pinViewYOffset]];
}

#pragma mark - Public methods

- (void)resetPinView
{
[self.pinView resetInput];
}

#pragma mark - Properties

- (void)setBackgroundColor:(UIColor *)backgroundColor
Expand Down Expand Up @@ -124,6 +134,33 @@ - (void)setPromptColor:(UIColor *)promptColor
self.pinView.promptColor = self.promptColor;
}

- (void)setPromptFont:(UIFont *)promptFont
{
if ([self.promptFont isEqual:promptFont]) {
return;
}
_promptFont = promptFont;
self.pinView.promptFont = self.promptFont;
}

- (void)setBottomButtonFont:(UIFont *)bottomButtonFont
{
if ([self.bottomButtonFont isEqual:bottomButtonFont]) {
return;
}
_bottomButtonFont = bottomButtonFont;
self.pinView.bottomButtonFont = self.bottomButtonFont;
}

- (void)setBottomButtonColor:(UIColor *)bottomButtonColor
{
if ([self.bottomButtonColor isEqual:bottomButtonColor]) {
return;
}
_bottomButtonColor = bottomButtonColor;
self.pinView.bottomButtonColor = self.bottomButtonColor;
}

- (void)setHideLetters:(BOOL)hideLetters
{
if (self.hideLetters == hideLetters) {
Expand Down
6 changes: 5 additions & 1 deletion THPinViewControllerExample/THViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ - (void)setLocked:(BOOL)locked

- (void)showPinViewAnimated:(BOOL)animated
{
UIColor *darkBlueColor = [UIColor colorWithRed:0.012f green:0.071f blue:0.365f alpha:1.0f];
THPinViewController *pinViewController = [[THPinViewController alloc] initWithDelegate:self];
pinViewController.view.tintColor = darkBlueColor;
pinViewController.promptTitle = @"Enter PIN";
UIColor *darkBlueColor = [UIColor colorWithRed:0.012f green:0.071f blue:0.365f alpha:1.0f];
pinViewController.promptColor = darkBlueColor;
pinViewController.promptFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:35.0];
pinViewController.bottomButtonFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0];
pinViewController.view.tintColor = darkBlueColor;
pinViewController.bottomButtonColor = darkBlueColor;

// for a solid background color, use this:
pinViewController.backgroundColor = [UIColor whiteColor];
Expand Down