Permalink
Browse files

Update to RegexKitLite 4.0, update IFTweetLabel to recognize phone nu…

…mbers (optional +, followed by 8 or more digits)
  • Loading branch information...
1 parent db709ae commit 5b41f68891657549b6091fa69f6e1ff7f88c97a8 Clawoo committed Dec 19, 2011
@@ -48,14 +48,14 @@ - (void)loadView {
[self.tweetLabel setTextColor:[UIColor whiteColor]];
[self.tweetLabel setBackgroundColor:[UIColor clearColor]];
[self.tweetLabel setNumberOfLines:0];
- [self.tweetLabel setText:@"This is a #test of regular expressions with http://example.com links as used in @Twitterrific. HTTP://CHOCKLOCK.COM APPROVED OF COURSE. 0744104747 123 123456 1234567"];
+ [self.tweetLabel setText:@"This is a #test of regular expressions with http://example.com links as used in @Twitterrific. HTTP://CHOCKLOCK.COM APPROVED OF COURSE. +21342234 123 123456 1234567"];
[self.tweetLabel setLinksEnabled:self.linksEnabled];
[contentView addSubview:self.tweetLabel];
CGRect frame = CGRectMake(100.0f, applicationFrame.size.height - 40.0f, applicationFrame.size.width - 200.0f, 22.0f);
UIButton *switchButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // autoreleased
[switchButton setFrame:frame];
- [switchButton setFont:[UIFont boldSystemFontOfSize:16.0f]];
+ [switchButton.titleLabel setFont:[UIFont boldSystemFontOfSize:16.0f]];
[switchButton setTitle:@"Switch" forState:UIControlStateNormal];
/*
Code like this can be used to customize the buttons that are placed on top of the label:
View
@@ -39,7 +39,7 @@ extern NSString *IFTweetLabelURLNotification;
@property (nonatomic, retain) UILabel *label;
-@property (assign) BOOL linksEnabled;
+@property (nonatomic, assign) BOOL linksEnabled;
- (void)setBackgroundColor:(UIColor *)backgroundColor;
- (void)setFrame:(CGRect)frame;
View
@@ -36,7 +36,7 @@ + (void)initialize
{
// setup regular expressions that define where buttons will be created
expressions = [[NSArray alloc] initWithObjects:
- @"([0-9]{7}+)", // screen names
+ @"(\\+)?([0-9]{8,}+)", // phone numbers, 8 or more
@"(@[a-zA-Z0-9_]+)", // screen names
@"(#[a-zA-Z0-9_-]+)", // hash tags
@"([hH][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)])", // hyperlinks
@@ -82,9 +82,9 @@ - (void)createButtonWithText:(NSString *)text withFrame:(CGRect)frame
button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // autoreleased
}
[button setFrame:frame];
- [button setFont:self.label.font];
+ [button.titleLabel setFont:self.label.font];
[button setTitle:text forState:UIControlStateNormal];
- [button setLineBreakMode:[self.label lineBreakMode]];
+ [button.titleLabel setLineBreakMode:[self.label lineBreakMode]];
[button setTitleColor:self.normalColor forState:UIControlStateNormal];
[button setTitleColor:self.highlightColor forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(handleButton:) forControlEvents:UIControlEventTouchUpInside];
Oops, something went wrong.

0 comments on commit 5b41f68

Please sign in to comment.