Skip to content

Commit

Permalink
Added search field attributes control
Browse files Browse the repository at this point in the history
  • Loading branch information
davbeck committed Dec 18, 2013
1 parent 2c8980a commit cf1cca0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions TURecipientBar/TURecipientsBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@
*/
@property (nonatomic, copy) NSDictionary *summaryTextAttributes UI_APPEARANCE_SELECTOR;

/** The text attributes applied to the search text field.
Only the font and foreground color are used.
*/
@property (nonatomic, copy) NSDictionary *searchFieldTextAttributes UI_APPEARANCE_SELECTOR;

/** The text attributes applied to the placeholder.
Note that at this time, changing summaryTextAttributes or recipientTitleTextAttributesForState: will not change the placeholder attributes.
Expand Down
23 changes: 21 additions & 2 deletions TURecipientBar/TURecipientsBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ - (void)_init

_textField = [[UITextField alloc] init];
_textField.text = TURecipientsPlaceholder;
_textField.font = [UIFont systemFontOfSize:15.0];
_textField.textColor = [UIColor blackColor];
_textField.delegate = self;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
_textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
Expand Down Expand Up @@ -919,14 +921,31 @@ - (NSDictionary *)recipientTitleTextAttributesForState:(UIControlState)state

- (void)setSummaryTextAttributes:(NSDictionary *)attributes
{
_summaryTextAttributes = attributes;
_summaryTextAttributes = [attributes copy];

[self _updateSummary];
}

- (void)setSearchFieldTextAttributes:(NSDictionary *)attributes
{
_searchFieldTextAttributes = [attributes copy];

if (_summaryTextAttributes[NSFontAttributeName] != nil) {
_textField.font = _summaryTextAttributes[NSFontAttributeName];
} else {
_textField.font = [UIFont systemFontOfSize:16.0];
}

if (_summaryTextAttributes[NSForegroundColorAttributeName] != nil) {
_textField.textColor = _summaryTextAttributes[NSForegroundColorAttributeName];
} else {
_textField.textColor = [UIColor blackColor];
}
}

- (void)setPlaceholderTextAttributes:(NSDictionary *)attributes
{
_placeholderTextAttributes = attributes;
_placeholderTextAttributes = [attributes copy];

[self _updateSummary];
}
Expand Down

0 comments on commit cf1cca0

Please sign in to comment.