UIImage+Extension.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // UIImage+Extension.h
  3. // HuaKaiChat
  4. //
  5. // Created by BigBiao on 2017/9/16.
  6. // Copyright © 2017年 huakai. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @interface UIImage (Extension)
  10. //获取屏幕截图
  11. + (UIImage *)screenshot;
  12. //切除图片的边角
  13. - (UIImage*)imageWithSize:(CGSize)size cornerRadius:(CGFloat)corner rectCornerType:(UIRectCorner)cornerType;
  14. //裁剪图片
  15. + (UIImage *)cutImage:(UIImage*)image isDT:(BOOL)flag;
  16. //根据视频URL地址,截取第一帧图片
  17. + (UIImage *)imageWithVideo:(NSURL *)videoURL;
  18. //根据颜色值拉伸成图片
  19. + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;
  20. //设置图片的透明度
  21. - (UIImage *)imageByApplyingAlpha:(CGFloat)alpha;
  22. //给图片加水印
  23. + (instancetype)waterImageWithBg:(UIImage*)bgImg centerImg:(NSString *)centerImg;
  24. //获取屏幕图片
  25. + (nullable UIImage*)screenView:(UIView *)view;
  26. + (UIImage *)imageWithScreenshot;
  27. //在图片最中间添加水印图片
  28. //循环压缩图片到制定大小
  29. - (NSData *)compressImageToMaxFileSize:(NSInteger)maxFileSize;
  30. //压到指定大小而且最大宽高小于1280
  31. +(NSData *)zipNSDataWithImage:(UIImage *)sourceImage maxFileSize:(NSInteger)maxFileSize;
  32. //图片压缩到指定大小1280*1280内
  33. - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize;
  34. @end
  35. //毛玻璃效果
  36. @interface UIImage (ImageEffects)
  37. - (UIImage *)applyLightEffect;
  38. - (UIImage *)applyExtraLightEffect;
  39. - (UIImage *)applyDarkEffect;
  40. - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
  41. //base init 方法
  42. //radius 是模糊处理半径,值越大,越模糊。
  43. //tintColor 遮盖层的颜色值
  44. //saturationDeltaFactor 色彩饱和度0是黑白色,1是原色,9代表最鲜艳,默认1.8
  45. //maskImage 遮盖图片 给nil
  46. - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
  47. //设置圆形图片
  48. - (UIImage *)cutCircleImage;
  49. //高斯模糊
  50. +(UIImage *)boxblurImage:(UIImage *)image withBlurNumber:(CGFloat)blur;
  51. @end