Skip to content

Commit

Permalink
Changed character count text color
Browse files Browse the repository at this point in the history
  • Loading branch information
smorris-chaione committed Aug 8, 2012
1 parent 6448003 commit 4fedfd0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions UIInputToolbarSample/Classes/UIInputToolbar/UIInputToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@

NSString * const CHExpandingTextViewWillChangeHeightNotification = @"CHExpandingTextViewWillChangeHeight";

@interface UIInputToolbar ()
@interface UIInputToolbar () {
UIColor *characterCountIsValidTextColor;
UIColor *characterCountIsValidShadowColor;
UIColor *characterCountIsNotValidTextColor;
UIColor *characterCountIsNotValidShadowColor;
}

@property (nonatomic, retain) UIButton *innerBarButton;

Expand Down Expand Up @@ -95,12 +100,17 @@ -(void)setupToolbar:(NSString *)buttonLabel
UIBarButtonItem *flexItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];

/* Add the character count label */
characterCountIsValidTextColor = [UIColor whiteColor];
characterCountIsValidShadowColor = [UIColor darkGrayColor];
characterCountIsNotValidTextColor = [UIColor redColor];
characterCountIsNotValidShadowColor = [UIColor clearColor];

characterCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(253, -5, 50, 40)];
characterCountLabel.textAlignment = UITextAlignmentCenter;
characterCountLabel.font = [UIFont boldSystemFontOfSize:12];
characterCountLabel.textColor = [UIColor darkGrayColor];
characterCountLabel.shadowColor = [UIColor whiteColor];
characterCountLabel.shadowOffset = CGSizeMake(0, 1);
characterCountLabel.textColor = characterCountIsValidTextColor;
characterCountLabel.shadowColor = characterCountIsValidShadowColor;
characterCountLabel.shadowOffset = CGSizeMake(0, -1);
characterCountLabel.backgroundColor = [UIColor clearColor];

[self addSubview:characterCountLabel];
Expand Down Expand Up @@ -184,10 +194,12 @@ -(void)expandingTextViewDidChange:(UIExpandingTextView *)expandingTextView
characterCountLabel.text = [NSString stringWithFormat:@"%i/%i",expandingTextView.text.length,characterLimit];

if (expandingTextView.text.length > characterLimit) {
characterCountLabel.textColor = [UIColor redColor];
characterCountLabel.textColor = characterCountIsNotValidTextColor;
characterCountLabel.shadowColor = characterCountIsNotValidShadowColor;
inputButton.enabled = NO;
} else if (expandingTextView.text.length > 0) {
characterCountLabel.textColor = [UIColor darkGrayColor];
characterCountLabel.textColor = characterCountIsValidTextColor;
characterCountLabel.shadowColor = characterCountIsValidShadowColor;
inputButton.enabled = YES;
}
}
Expand Down

0 comments on commit 4fedfd0

Please sign in to comment.