From 68230e5699a8326950bd3208c06258789dec8cc3 Mon Sep 17 00:00:00 2001 From: Andrew Small Date: Thu, 9 Apr 2015 23:40:56 -0600 Subject: [PATCH 1/4] Allow input text field font customization. --- VENTokenField/VENTokenField.h | 1 + VENTokenField/VENTokenField.m | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/VENTokenField/VENTokenField.h b/VENTokenField/VENTokenField.h index b4c81c4..7dc17dd 100644 --- a/VENTokenField/VENTokenField.h +++ b/VENTokenField/VENTokenField.h @@ -66,6 +66,7 @@ @property (assign, nonatomic) UIView *inputTextFieldAccessoryView; @property (strong, nonatomic) UIColor *toLabelTextColor; @property (strong, nonatomic) NSString *toLabelText; +@property (strong, nonatomic) UIFont *inputTextFieldFont; @property (strong, nonatomic) UIColor *inputTextFieldTextColor; @property (strong, nonatomic) UILabel *toLabel; diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 3512062..184b9bb 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -129,6 +129,12 @@ -(void)setInputTextFieldAccessibilityLabel:(NSString *)inputTextFieldAccessibili self.inputTextField.accessibilityLabel = _inputTextFieldAccessibilityLabel; } +- (void)setInputTextFieldFont:(UIFont *)inputTextFieldFont +{ + _inputTextFieldFont = inputTextFieldFont; + self.inputTextField.font = inputTextFieldFont; +} + - (void)setInputTextFieldTextColor:(UIColor *)inputTextFieldTextColor { _inputTextFieldTextColor = inputTextFieldTextColor; From 0f20a7194b9f3aafccd34a5c910836077e4d8b11 Mon Sep 17 00:00:00 2001 From: Andrew Small Date: Fri, 10 Apr 2015 13:36:51 -0600 Subject: [PATCH 2/4] Podfile update. --- Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 3062fb9..4948dd8 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,8 +1,8 @@ PODS: - FrameAccessor (1.3.2) - - KIF (3.1.2): - - KIF/XCTest (= 3.1.2) - - KIF/XCTest (3.1.2) + - KIF (3.2.1): + - KIF/XCTest (= 3.2.1) + - KIF/XCTest (3.2.1) - VENTokenField (2.3.0): - FrameAccessor (~> 1.0) @@ -16,7 +16,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FrameAccessor: 0f7ba6ce37be9a5d0302a27c731dca70af8d438b - KIF: e08915d78a220480599837e9a760deee64453d76 + KIF: ef1691e54e1d969c3b4fd0b5b56a3d7ddf37f216 VENTokenField: ec847952d7a6d4ad65cb8ba2fc8141ab26a041fa COCOAPODS: 0.36.3 From 4358e5324ef9edc719ca3d6c10b19cd5dfcc7c91 Mon Sep 17 00:00:00 2001 From: Andrew Small Date: Mon, 13 Apr 2015 20:13:39 -0600 Subject: [PATCH 3/4] Allow custom token font. --- VENTokenField/VENToken.h | 1 + VENTokenField/VENToken.m | 6 ++++++ VENTokenField/VENTokenField.h | 1 + VENTokenField/VENTokenField.m | 7 +++++++ VENTokenFieldSample/Base.lproj/Main.storyboard | 13 ++++++++++--- VENTokenFieldSample/ViewController.m | 10 ++++++++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/VENTokenField/VENToken.h b/VENTokenField/VENToken.h index 21768cb..e11a4e8 100644 --- a/VENTokenField/VENToken.h +++ b/VENTokenField/VENToken.h @@ -27,6 +27,7 @@ @property (assign, nonatomic) BOOL highlighted; @property (copy, nonatomic) void (^didTapTokenBlock) (void); @property (strong, nonatomic) UIColor *colorScheme; +@property (strong, nonatomic) UIFont *font; - (void)setTitleText:(NSString *)text; diff --git a/VENTokenField/VENToken.m b/VENTokenField/VENToken.m index 4435a83..93fe35a 100644 --- a/VENTokenField/VENToken.m +++ b/VENTokenField/VENToken.m @@ -52,6 +52,7 @@ - (void)setTitleText:(NSString *)text { self.titleLabel.text = text; self.titleLabel.textColor = self.colorScheme; + self.titleLabel.font = self.font; [self.titleLabel sizeToFit]; self.frame = CGRectMake(CGRectGetMinX(self.frame), CGRectGetMinY(self.frame), CGRectGetMaxX(self.titleLabel.frame) + 3, CGRectGetHeight(self.frame)); [self.titleLabel sizeToFit]; @@ -73,6 +74,11 @@ - (void)setColorScheme:(UIColor *)colorScheme [self setHighlighted:_highlighted]; } +- (void)setFont:(UIFont *)font { + _font = font; + [self setTitleText:self.titleLabel.text]; +} + #pragma mark - Private diff --git a/VENTokenField/VENTokenField.h b/VENTokenField/VENTokenField.h index 7dc17dd..195a7f7 100644 --- a/VENTokenField/VENTokenField.h +++ b/VENTokenField/VENTokenField.h @@ -68,6 +68,7 @@ @property (strong, nonatomic) NSString *toLabelText; @property (strong, nonatomic) UIFont *inputTextFieldFont; @property (strong, nonatomic) UIColor *inputTextFieldTextColor; +@property (strong, nonatomic) UIFont *tokenFont; @property (strong, nonatomic) UILabel *toLabel; diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 184b9bb..5e36933 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -93,6 +93,7 @@ - (void)setUpInit self.tokenPadding = VENTokenFieldDefaultTokenPadding; self.minInputWidth = VENTokenFieldDefaultMinInputWidth; self.colorScheme = [UIColor blueColor]; + self.tokenFont = [UIFont fontWithName:@"HelveticaNeue" size:15.5]; self.toLabelTextColor = [UIColor colorWithRed:112/255.0f green:124/255.0f blue:124/255.0f alpha:1.0f]; self.inputTextFieldTextColor = [UIColor colorWithRed:38/255.0f green:39/255.0f blue:41/255.0f alpha:1.0f]; @@ -163,6 +164,11 @@ - (void)setColorScheme:(UIColor *)color } } +- (void)setTokenFont:(UIFont *)tokenFont { + _tokenFont = tokenFont; + [self setNeedsLayout]; +} + - (void)setInputTextFieldAccessoryView:(UIView *)inputTextFieldAccessoryView { _inputTextFieldAccessoryView = inputTextFieldAccessoryView; @@ -305,6 +311,7 @@ - (void)layoutTokensWithCurrentX:(CGFloat *)currentX currentY:(CGFloat *)current NSString *title = [self titleForTokenAtIndex:i]; VENToken *token = [[VENToken alloc] init]; token.colorScheme = self.colorScheme; + token.font = self.tokenFont; __weak VENToken *weakToken = token; __weak VENTokenField *weakSelf = self; diff --git a/VENTokenFieldSample/Base.lproj/Main.storyboard b/VENTokenFieldSample/Base.lproj/Main.storyboard index 07f1261..dce038c 100644 --- a/VENTokenFieldSample/Base.lproj/Main.storyboard +++ b/VENTokenFieldSample/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -38,6 +38,13 @@ + + + + + + + diff --git a/VENTokenFieldSample/ViewController.m b/VENTokenFieldSample/ViewController.m index 073f85f..3eee6f8 100644 --- a/VENTokenFieldSample/ViewController.m +++ b/VENTokenFieldSample/ViewController.m @@ -38,6 +38,16 @@ - (IBAction)didTapResignFirstResponderButton:(id)sender [self.tokenField resignFirstResponder]; } +- (IBAction)fontChanged:(UISwitch *)sender +{ + if (sender.isOn) { + self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeue" size:15.5]; + } + else { + self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeueBold" size:15.5]; + } +} + #pragma mark - VENTokenFieldDelegate From 045d61b35c0eeeae1a3523173a16903f6f5cb87b Mon Sep 17 00:00:00 2001 From: Andrew Small Date: Mon, 13 Apr 2015 20:18:53 -0600 Subject: [PATCH 4/4] Better sample UI for testing token font. --- VENTokenFieldSample/Base.lproj/Main.storyboard | 11 +++++++++-- VENTokenFieldSample/ViewController.m | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/VENTokenFieldSample/Base.lproj/Main.storyboard b/VENTokenFieldSample/Base.lproj/Main.storyboard index dce038c..cfbd531 100644 --- a/VENTokenFieldSample/Base.lproj/Main.storyboard +++ b/VENTokenFieldSample/Base.lproj/Main.storyboard @@ -38,8 +38,15 @@ - - + + + diff --git a/VENTokenFieldSample/ViewController.m b/VENTokenFieldSample/ViewController.m index 3eee6f8..6e08c2f 100644 --- a/VENTokenFieldSample/ViewController.m +++ b/VENTokenFieldSample/ViewController.m @@ -41,10 +41,10 @@ - (IBAction)didTapResignFirstResponderButton:(id)sender - (IBAction)fontChanged:(UISwitch *)sender { if (sender.isOn) { - self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeue" size:15.5]; + self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeueBold" size:15.5]; } else { - self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeueBold" size:15.5]; + self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeue" size:15.5]; } }