RQConstInline.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RQConstInline.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/20.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #ifndef RQConstInline_h
  9. #define RQConstInline_h
  10. /// 网络图片的占位图片
  11. static inline UIImage *RQWebImagePlaceholder(){
  12. return [UIImage imageNamed:@"placeholder_image"];
  13. }
  14. /// 网络头像
  15. static inline UIImage *RQWebAvatarImagePlaceholder(){
  16. return [UIImage imageNamed:@"头像"];
  17. }
  18. /// 适配
  19. static inline CGFloat RQPxConvertToPt(CGFloat px){
  20. return ceil(px * [UIScreen mainScreen].bounds.size.width/414.0f);
  21. }
  22. /// 辅助方法 创建一个文件夹
  23. static inline void RQCreateDirectoryAtPath(NSString *path){
  24. BOOL isDir = NO;
  25. BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
  26. if (isExist) {
  27. if (!isDir) {
  28. [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
  29. [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
  30. }
  31. } else {
  32. [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
  33. }
  34. }
  35. /// 微信重要数据备份的文件夹路径,通过NSFileManager来访问
  36. static inline NSString *RQWeChatDocDirPath(){
  37. return [RQDocumentDirectory stringByAppendingPathComponent:RQ_WECHAT_DOC_NAME];
  38. }
  39. /// 通过NSFileManager来获取指定重要数据的路径
  40. static inline NSString *RQFilePathFromWeChatDoc(NSString *filename){
  41. NSString *docPath = RQWeChatDocDirPath();
  42. RQCreateDirectoryAtPath(docPath);
  43. return [docPath stringByAppendingPathComponent:filename];
  44. }
  45. /// 微信轻量数据备份的文件夹路径,通过NSFileManager来访问
  46. static inline NSString *RQWeChatCacheDirPath(){
  47. return [RQCachesDirectory stringByAppendingPathComponent:RQ_WECHAT_CACHE_NAME];
  48. }
  49. /// 通过NSFileManager来访问 获取指定轻量数据的路径
  50. static inline NSString *RQFilePathFromWeChatCache(NSString *filename){
  51. NSString *cachePath = RQWeChatCacheDirPath();
  52. RQCreateDirectoryAtPath(cachePath);
  53. return [cachePath stringByAppendingPathComponent:filename];
  54. }
  55. #endif /* RQConstInline_h */