此文純?yōu)樽约簜渫?,不喜勿噴,默默關(guān)掉!
1.改變狀態(tài)欄顏色
(1)在info.plist文件中改

(2)代碼更改
//設(shè)置狀態(tài)欄顏色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
(3)可在General中修改

2.設(shè)置Navagation和TabBar
//設(shè)置導(dǎo)航欄背景顏色和字體顏色
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}];
//tabBar的背景顏色
[[UITabBar appearance] setBarTintColor:[UIColor blackColor]];
//[[UITabBar appearance] setOpaque:YES];
//tabBar的字體大小和選中之后的顏色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} forState:UIControlStateNormal];//字體大小
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateSelected];//設(shè)置字體的渲染顏色
3.imageWithColor是顏色轉(zhuǎn)換成image的一個(gè)方法
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
CGRect rect = CGRectMake( 0.0f, 0.0f, size.width, size.height );
UIGraphicsBeginImageContext( rect.size );
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage * result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
4.郵箱,手機(jī)號(hào),身份證號(hào)等判斷
//郵箱
+ (BOOL) validateEmail:(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];
}
//手機(jī)號(hào)碼驗(yàn)證
+ (BOOL) validateMobile:(NSString *)mobile {
//手機(jī)號(hào)以13, 15,18開頭,八個(gè) \d 數(shù)字字符
NSString *phoneRegex = @"^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
return [phoneTest evaluateWithObject:mobile];
}
//用戶(正則判斷A-Z,a-z,0-9且6到20位)
+ (BOOL) validateUserName:(NSString *)name {
NSString *userNameRegex = @"^[A-Za-z0-9]{6,20}+$";
NSPredicate *userNamePredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",userNameRegex];
BOOL B = [userNamePredicate evaluateWithObject:name];
return B;
}
//密碼
+ (BOOL) validatePassword:(NSString *)passWord {
NSString *passWordRegex = @"^[a-zA-Z0-9]{6,12}+$";
NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
return [passWordPredicate evaluateWithObject:passWord];
}
//身份證號(hào)
+ (BOOL) validateIdentityCard: (NSString *)identityCard {
BOOL flag;
if (identityCard.length <= 0) {
flag = NO;
return flag;
}
NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
return [identityCardPredicate evaluateWithObject:identityCard];
}
//數(shù)字
+ (BOOL) validateCount: (NSString *)count {
NSString *countRegex = @"^[0-9]*$";
NSPredicate *countTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", countRegex];
return [countTest evaluateWithObject:count];
}
//網(wǎng)址
+ (BOOL) validateURL:(NSString *)URL
NSString *URLRegex1 = @"^\\w+((\\-\\w+)|(\\.\\w+))*@[A-Za-z0-9]+((\\.|\\-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$";
NSPredicate *URLTest1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", URLRegex1];
NSString *URLRegex2 = @"http+:[^\\s]*";
NSPredicate *URLTest2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", URLRegex2];
if ([URLTest1 evaluateWithObject:URL] == YES || [URLTest2 evaluateWithObject:URL] == YES) {
return YES;
}else {
return NO;
}