Skip to content
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
1 change: 1 addition & 0 deletions VENTokenField/VENToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions VENTokenField/VENToken.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions VENTokenField/VENTokenField.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
@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) UIFont *tokenFont;

@property (strong, nonatomic) UILabel *toLabel;

Expand Down
13 changes: 13 additions & 0 deletions VENTokenField/VENTokenField.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -129,6 +130,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;
Expand Down Expand Up @@ -157,6 +164,11 @@ - (void)setColorScheme:(UIColor *)color
}
}

- (void)setTokenFont:(UIFont *)tokenFont {
_tokenFont = tokenFont;
[self setNeedsLayout];
}

- (void)setInputTextFieldAccessoryView:(UIView *)inputTextFieldAccessoryView
{
_inputTextFieldAccessoryView = inputTextFieldAccessoryView;
Expand Down Expand Up @@ -298,6 +310,7 @@ - (void)layoutTokensWithCurrentX:(CGFloat *)currentX currentY:(CGFloat *)current
for (NSUInteger i = 0; i < [self numberOfTokens]; i++) {
NSString *title = [self titleForTokenAtIndex:i];
VENToken *token = [[VENToken alloc] init];
token.font = self.tokenFont;

__weak VENToken *weakToken = token;
__weak VENTokenField *weakSelf = self;
Expand Down
20 changes: 17 additions & 3 deletions VENTokenFieldSample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment defaultVersion="1808" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand Down Expand Up @@ -38,6 +38,20 @@
<action selector="didTapResignFirstResponderButton:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Pjv-6d-781"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Bold Tokens" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3FI-UR-Ond">
<rect key="frame" x="24" y="273" width="95" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="LYb-QX-Gds">
<rect key="frame" x="127" y="268" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="fontChanged:" destination="vXZ-lx-hvc" eventType="valueChanged" id="2pE-rH-ZJb"/>
</connections>
</switch>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
</view>
Expand Down
10 changes: 10 additions & 0 deletions VENTokenFieldSample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ - (IBAction)didTapResignFirstResponderButton:(id)sender
[self.tokenField resignFirstResponder];
}

- (IBAction)fontChanged:(UISwitch *)sender
{
if (sender.isOn) {
self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeueBold" size:15.5];
}
else {
self.tokenField.tokenFont = [UIFont fontWithName:@"HelveticaNeue" size:15.5];
}
}


#pragma mark - VENTokenFieldDelegate

Expand Down