IOS系列——小功能代码整理
来源:互联网 发布:炉石传说 德鲁伊 知乎 编辑:程序博客网 时间:2024/05/01 17:30
1.正则表达式:邮箱验证
-(BOOL)isValidateEmail:(NSString *)email{NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex];return [emailTest evaluateWithObject:email];}
2.正则表达式:电话号码验证
+ (BOOL)checkTel:(NSString *)str{ //1[0-9]{10} //^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$ // NSString *regex = @"[0-9]{11}"; NSString *regex = @"^((13[0-9])|(147)|(15[0-3,5-9])|(17[0,6-8])|(18[0-9]))\\d{8}$"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; return [pred evaluateWithObject:str];}
3.拨打电话
//拨打电话#define canTel ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:"]])#define tel(phoneNumber) ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]])#define telprompt(phoneNumber) ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phoneNumber]]])
4.影藏statusBar
[[UIApplication sharedApplication]setStatusBarHidden:YES animated:NO];
5.更改AlertView的背景
UIAlertView *theAlert = [[[UIAlertViewalloc] initWithTitle:@"Atention"message: @"I'm a Chinese!"delegate:nilcancelButtonTitle:@"Cancel"otherButtonTitles:@"Okay",nil] autorelease];[theAlert show];UIImage *theImage = [UIImageimageNamed:@"loveChina.png"];theImage = [theImage stretchableImageWithLeftCapWidth:0topCapHeight:0];CGSize theSize = [theAlert frame].size;UIGraphicsBeginImageContext(theSize);[theImage drawInRect:CGRectMake(5, 5, theSize.width-10, theSize.height-20)];//这个地方的大小要自己调整,以适应alertview的背景颜色的大小。theImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();theAlert.layer.contents = (id)[theImage CGImage];
6.设置键盘透明
textField.keyboardAppearance = UIKeyboardAppearanceAlert;
7.状态栏的网络活动指示是否显示
[UIApplication sharedApplication].networkActivityIndicatorVisible,默认值是NO。
0 0
- IOS系列——小功能代码整理
- ios系列——导航条整理
- Ios常用一些小代码整理
- iOS 的小功能代码段
- iOS 常用小功能——打电话
- js 小功能 整理
- js小功能整理
- 小功能整理
- IOS系列——tabbar代码添加
- IOS系列——iPhone开发中的技巧整理
- IOS开发系列——Widget专题【整理】
- IOS开发系列——Block专题【整理,部分原创】
- IOS开发系列——UIWebView专题【整理,部分原创】
- iOS开发中一些小功能代码(持续更新)
- IOS系列——导航条UINavigationController的简单功能
- 小代码整理
- iOS操作小整理
- iOS 常用小功能——发短信
- Handler结合progressBar(进度条)使用方法
- 教你怎么快速掌握GIS(电子地图)引擎的开发,并且快速实现相应的功能特效
- 多态 和 重载的区别
- hdu 4961 Boring Sum
- linux函数之ifconfig
- IOS系列——小功能代码整理
- 数据结构排序算法总结
- 有一个视频据说不错。介绍chrome开发者工具的。
- 10种超经典的软件滤波方法,你值得拥有!
- Linux设置静态ip
- EditText相关
- Codeforce--414B--Mashmokh and ACM
- lianjie
- gdiplus Bitmap 转 gdi BITMAP