PublicObj.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // PublicObj.h
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/6/6.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <Photos/Photos.h>
  10. #import "YBTabBarController.h"
  11. #import "YBButton.h"
  12. typedef void (^ThumbSizeBlock)(CGFloat width,CGFloat height);
  13. typedef void (^RoomIMNumBlock)(int pUnread);
  14. typedef void (^TokenAccessBlock)(BOOL isAccess);
  15. typedef void(^GoodsExistenceEvent)(int code, NSString *msg);
  16. @interface PublicObj : NSObject
  17. +(instancetype)publicInstance;
  18. - (void)addSystemVolumeView;
  19. - (void)removeSystemVolumeView;
  20. - (void)addCusDelayedRemove;
  21. /**
  22. 计算字符串宽度
  23. @param str 字符串
  24. @param font 字体
  25. @param height 高度
  26. @return 宽度
  27. */
  28. - (CGFloat)widthOfString:(NSString *)str andFont:(UIFont *)font andHeight:(CGFloat)height;
  29. + (CGFloat)widthOfString:(NSString *)str andFont:(UIFont *)font andHeight:(CGFloat)height;
  30. /**
  31. 计算字符串的高度
  32. @param str 字符串
  33. @param font 字体
  34. @param width 宽度
  35. @return 高度
  36. */
  37. + (CGFloat)heightOfString:(NSString *)str andFont:(UIFont *)font andWidth:(CGFloat)width;
  38. /** 单行文本长度计算 */
  39. +(CGSize)sizeWithString:(NSString *)string andFont:(UIFont *)font;
  40. /** 多行计算frame */
  41. +(CGRect)rectWithString:(NSString *)string andFont:(UIFont *)font maxWidth:(CGFloat)width;
  42. /** token过期 */
  43. +(void)tokenExpired:(NSString *)msg;
  44. /** 返回游客信息 */
  45. +(NSDictionary *)visitorDic;
  46. /** 提醒游客请登录 */
  47. +(void)warnLogin;
  48. /** 根据色值获取图片 */
  49. +(UIImage*)getImgWithColor:(UIColor *)color;
  50. +(UIImage*)getImgWithColor:(UIColor *)color withSize:(CGSize)size;
  51. /** 设置上图下文字 */
  52. +(UIButton*)setUpImgDownText:(UIButton *)btn;
  53. /** 自定义间距上图下文字 */
  54. +(UIButton*)setUpImgDownText:(UIButton *)btn space:(CGFloat)space;
  55. /** 重设root */
  56. +(void)resetVC:(UIViewController*)vc;
  57. /** 根据图片名拼接文件路径 */
  58. +(NSString *)getFilePathWithImageName:(NSString *)imageName;
  59. /** 以当前时间合成视频名称 */
  60. +(NSString *)getNameBaseCurrentTime:(NSString *)suf;
  61. /** 判断是不是本地视频 */
  62. +(BOOL)judgeAssetisInLocalAblum:(PHAsset *)asset;
  63. /** 权限相关 */
  64. +(BOOL)havePhotoLibraryAuthority;
  65. /** 原图-小-恢复 */
  66. +(CAAnimation*)bigToSmallRecovery;
  67. /** 原图-大-小*/
  68. +(CAAnimation*)smallToBigToSmall;
  69. /** 原图-小-保持 */
  70. +(CAAnimation*)originToSmall;
  71. /** 原图-大-小-恢复 */
  72. +(CAAnimation*)originToBigToSmallRecovery;
  73. /* 观看页面上下切换,并且未关注的情况下的过渡动画 */
  74. +(CAAnimation*)followShowTransition;
  75. /** 按钮按下执行动画(录音) */
  76. +(CAAnimation*)touchDownAnimation;
  77. /** 旋转动画 */
  78. +(CABasicAnimation*)rotationAnimation;
  79. /** 动画组 */
  80. +(CAAnimationGroup*)caGroup;
  81. /** MD5 */
  82. +(NSString *)stringToMD5:(NSString *)str;
  83. /** 检查为空 */
  84. +(BOOL)checkNull:(NSString *)str;
  85. /** 双击点赞 */
  86. +(void)doubleClickShowZan:(UIView *)sueprView withCenter:(CGPoint )center;
  87. /** 创建emoji正则表达式 */
  88. +(NSArray <NSTextCheckingResult *> *)machesWithPattern:(NSString *)pattern andStr:(NSString *)str;
  89. /** 画一条线 */
  90. +(UIView *)lineViewWithFrame:(CGRect)frame andColor:(UIColor *)color andView:(UIView *)view;
  91. /** 获取系统音量滑块 */
  92. +(UISlider*)setSystemVolumSliderWithSuperViwe:(UIViewController *)superView;
  93. +(CGFloat)getSysOutputVolume;
  94. /** 获取缩略图 */
  95. +(UIImage*)getVideoPreViewImageWithPath:(NSURL *)videoPath;
  96. /** 获取启动图 */
  97. + (UIImage *)getLaunchImage;
  98. /** 获取版本号 */
  99. +(NSString *)getAppBuild;
  100. +(BOOL)isUp;
  101. +(NSString *)getAppName;
  102. +(CGFloat)getSysVersion;
  103. +(UIImage *)getAppIcon;
  104. /** 字典字符串加(解)密排序 */
  105. + (NSString *)sortString:(NSDictionary *)dic;
  106. + (NSString *)decrypt:(NSString *)code;
  107. /** 小程序 */
  108. + (void)openWXMiniProgram:(NSString *)path;
  109. /** git 转 data */
  110. +(NSData *)gifConvertDataWithName:(NSString *)gifName;
  111. /** 封面width、height */
  112. +(void)getThumbSizeWithUrl:(NSString *)url complete:(ThumbSizeBlock)complete;
  113. /** 获取UUID */
  114. +(NSString *)getDeviceUUID;
  115. /** 设置视图左上圆角 */
  116. +(CAShapeLayer *)setViewLeftTop:(CGFloat)leftC andRightTop:(CGFloat)rightC andView:(UIView *)view;
  117. /** 图片压缩相关 */
  118. +(UIImage*)scaleImage:(UIImage *)image scaleToSize:(CGSize)size;
  119. +(CGSize)getObjSize:(CGSize)sourceSize;
  120. /** 渐变色
  121. * dire:0-横向 1-纵向 2-斜向
  122. */
  123. +(void)addGradientWithFromColor:(UIColor *)formColor andEndColor:(UIColor *)endColor andView:(UIView *)view direction:(int)dire;
  124. /** 比较两个时间的大小(date01 老的时间、date02 新的时间 返回 1 -1 0)*/
  125. +(int)compareDate:(NSString*)date01 withDate:(NSString*)date02;
  126. /** 网络类型、手机类型*/
  127. + (NSString *)getNetworkType;
  128. /// 此方法谨慎使用【使用到了私有属性,随着系统的升级有可能面临苹果的禁用】
  129. + (int)getSignalStrength;
  130. + (NSString *)iphoneType;
  131. +(void)saveNetReachability:(NSString *)save;
  132. + (NSInteger)getDeviceType;
  133. /** 更新pushid */
  134. +(void)updatePushId:(NSString *)pushId;
  135. /** 重置为游客 */
  136. +(void)resetUserToVisitor;
  137. +(YBTabBarController *)currentTabbar;
  138. /** 背景模糊图 */
  139. +(UIImageView *)getAvatarEffectWithUrl:(NSString *)avatarUrl;
  140. +(UIImageView *)getAvatarEffectWithUrl:(NSString *)avatarUrl andFrame:(CGRect)effectFrame;
  141. /** 直播中头像动画 */
  142. +(CAKeyframeAnimation *)avatarScaleAnimation;
  143. +(CAKeyframeAnimation *)bottomScaleAnimation;
  144. /** 获取私信未读数量【去除:粉丝、赞、AT、评论、官方】 */
  145. //+(void)getRoomImUnread:(RoomIMNumBlock)complete;
  146. /** 是否开启了粗体文本 */
  147. +(BOOL)isBlodText;
  148. /** 更新同城tab名称 */
  149. +(NSString *)updataNewCity:(NSString *)cityName;
  150. /** token 验证*/
  151. +(void)tokenAccess:(TokenAccessBlock)complete;
  152. +(void)checkGoodsExistenceWithID:(NSString *)goosID Existence:(GoodsExistenceEvent)existence;
  153. +(YBButton *)youngAlertBtn;
  154. #pragma mark - 各类window弹窗层级布局
  155. +(void)layoutWindowPopLayer;
  156. #pragma mark - 拒绝协议杀掉app
  157. +(void)appDestroy;
  158. #pragma mark - 美颜
  159. +(BOOL)isBaseBeauty;
  160. +(YBBaseViewController *)currentViewContorller;
  161. +(NSString *)getDateDisplayString:(NSDate *)date;
  162. +(NSString *)getUserDateString:(NSDate *)date;
  163. + (NSString *)getFriendlyDateString:(NSTimeInterval)timeInterval
  164. forConversation:(BOOL)isShort;
  165. #pragma mark - data转字符串
  166. +(NSString *)transformToStringWithData:(id)originData;
  167. + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
  168. + (BOOL)isUrlString:(NSString *)string ;
  169. #pragma mark - tabbar消息未读
  170. +(void)setTabbarBadgeValue:(int)value;
  171. #pragma mark - 数据格式检验、转换
  172. +(NSArray *)toArrayOfInfo:(id)info;
  173. +(NSDictionary *)toDicOfInfo:(id)info;
  174. @end