This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 正则验证 | |
NSError *error; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^1\\d{10}$" | |
options:NSRegularExpressionCaseInsensitive | |
error:&error]; | |
NSUInteger count = [regex numberOfMatchesInString:userPhone | |
options:NSRegularExpressionCaseInsensitive | |
range:NSMakeRange(0, [userPhone length])]; | |
// 格式验证失败 | |
if (count != 1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *) createImageWithColor: (UIColor *) color | |
{ | |
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(context, [color CGColor]); | |
CGContextFillRect(context, rect); | |
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
NewerOlder