#pragma mark -- 获取手机系统+ (NSString *)getSystemVersion { NSString *phoneVersion = [[UIDevice currentDevice] systemVersion]; return phoneVersion;}
#pragma mark -- 获取当前appname+ (NSString *)appName{ NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"]; return app_Name;}
#pragma mark -- 获取当前appVersion+ (NSString *)appVersion{ NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; return app_Version;}
#pragma mark -- 获取当前Verison+ (NSString *)appBuild { NSString *build = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; return build;}
#pragma mark -- 存储大小+ (CGFloat)totalDiskSpace { NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil]; NSNumber *folderSize = [fattributes objectForKey:NSFileSystemSize]; float sizeM = [folderSize floatValue] /1024.0/1024.0; return sizeM;}
#pragma mark -- 可用存储大小+ (CGFloat)freeDiskSpace { NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil]; NSNumber *folderSize = [fattributes objectForKey:NSFileSystemFreeSize]; float sizeM = [folderSize floatValue] /1024.0/1024.0; return sizeM;}
//根据高度度求宽度 text 计算的内容 Height 计算的高度 font字体大小+ (CGFloat)getWidthWithText:(NSString *)text height:(CGFloat)height font:(CGFloat)font{ CGRect rect = [text boundingRectWithSize:CGSizeMake(MAXFLOAT, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil]; return rect.size.width;}
///获取文字高度+ (CGFloat)getHeightWithText:(NSString *)text width:(CGFloat)textWidth fontSize:(UIFont *)font{ NSDictionary *dict = @{NSFontAttributeName:font}; CGRect rect = [text boundingRectWithSize:CGSizeMake(textWidth, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil]; //返回计算出的行高 return rect.size.height;}
///单数设置组件的上下左右边框+ (void)setBorderWithView:(UIView *)view top:(BOOL)top left:(BOOL)left bottom:(BOOL)bottom right:(BOOL)right borderColor:(UIColor *)color borderWidth:(CGFloat)width{ if (top) { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(0, 0, view.frame.size.width, width); layer.backgroundColor = color.CGColor; [view.layer addSublayer:layer]; } if (left) { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(0, 0, width, view.frame.size.height); layer.backgroundColor = color.CGColor; [view.layer addSublayer:layer]; } if (bottom) { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(0, view.frame.size.height - width, view.frame.size.width, width); layer.backgroundColor = color.CGColor; [view.layer addSublayer:layer]; } if (right) { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(view.frame.size.width - width, 0, width, view.frame.size.height); layer.backgroundColor = color.CGColor; [view.layer addSublayer:layer]; }}
///获取HTML标签中的信息+ (NSString *)filterHTML:(NSString *)html{ NSDictionary *dic = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType}; NSData *data = [html dataUsingEncoding:NSUnicodeStringEncoding]; NSAttributedString *attriStr = [[NSAttributedString alloc] initWithData:data options:dic documentAttributes:nil error:nil]; NSString *str = attriStr.string; str = [str stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; return str; }