123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // RQConstInline.h
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/20.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #ifndef RQConstInline_h
- #define RQConstInline_h
- /// 网络图片的占位图片
- static inline UIImage *RQWebImagePlaceholder(){
- return [UIImage imageNamed:@"placeholder_image"];
- }
- /// 网络头像
- static inline UIImage *RQWebAvatarImagePlaceholder(){
- return [UIImage imageNamed:@"头像"];
- }
- /// 适配
- static inline CGFloat RQPxConvertToPt(CGFloat px){
- return ceil(px * [UIScreen mainScreen].bounds.size.width/414.0f);
- }
- /// 辅助方法 创建一个文件夹
- static inline void RQCreateDirectoryAtPath(NSString *path){
- BOOL isDir = NO;
- BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
- if (isExist) {
- if (!isDir) {
- [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
- [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
- }
- } else {
- [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
- }
- }
- /// 微信重要数据备份的文件夹路径,通过NSFileManager来访问
- static inline NSString *RQWeChatDocDirPath(){
- return [RQDocumentDirectory stringByAppendingPathComponent:RQ_WECHAT_DOC_NAME];
- }
- /// 通过NSFileManager来获取指定重要数据的路径
- static inline NSString *RQFilePathFromWeChatDoc(NSString *filename){
- NSString *docPath = RQWeChatDocDirPath();
- RQCreateDirectoryAtPath(docPath);
- return [docPath stringByAppendingPathComponent:filename];
- }
- /// 微信轻量数据备份的文件夹路径,通过NSFileManager来访问
- static inline NSString *RQWeChatCacheDirPath(){
- return [RQCachesDirectory stringByAppendingPathComponent:RQ_WECHAT_CACHE_NAME];
- }
- /// 通过NSFileManager来访问 获取指定轻量数据的路径
- static inline NSString *RQFilePathFromWeChatCache(NSString *filename){
- NSString *cachePath = RQWeChatCacheDirPath();
- RQCreateDirectoryAtPath(cachePath);
- return [cachePath stringByAppendingPathComponent:filename];
- }
- #endif /* RQConstInline_h */
|