UIImage+QQCorner.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // UIImage+QQCorner.h
  3. // QQCorner
  4. //
  5. // Created by 秦琦 on 2018/10/24.
  6. // Copyright © 2018 QinQi. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "QQCornerModel.h"
  10. @interface UIImage (QQCorner)
  11. /**
  12. Add corner to a UIImage instance.
  13. 给一个UIImage对象添加圆角
  14. @param radius The radiuses of 4 corners.
  15. 4个圆角的半径
  16. */
  17. - (UIImage *)imageByAddingCornerRadius:(QQRadius)radius;
  18. /**
  19. Create a UIImage by UIColor.
  20. 通过颜色创建图片,大小为 1 x 1
  21. */
  22. + (UIImage *)imageWithColor:(UIColor *)color;
  23. /**
  24. Create a UIImage with corner by UIColor.
  25. 通过颜色创建带圆角的图片
  26. @param color The color of the image.
  27. 图片的颜色
  28. @param size The size of the image.
  29. 图片的尺寸
  30. @param radius The radiuses of 4 corners.
  31. 4个圆角的半径
  32. */
  33. + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size cornerRadius:(QQRadius)radius;
  34. /**
  35. Create a UIImage with the contents of a layer.
  36. 将layer的内容渲染为图片
  37. @param layer Whose contents will be rendered in the image.
  38. 将要被渲染到图片的layer
  39. @param radius The radiuses of 4 corners. If you pass QQRadiusZero, the final image will not add corner
  40. 4个圆角的半径,如果传入QQRadiusZero,最终的图片将不添加圆角
  41. */
  42. + (UIImage *)imageWithLayer:(CALayer *)layer cornerRadius:(QQRadius)radius;
  43. /**
  44. Create a UIImage with gradual changing color.
  45. 创建一个渐变色的图片
  46. @param graColor gradual changing color properties.
  47. 渐变色的属性
  48. @param size The size of the image.
  49. 图片的尺寸
  50. @param radius The radiuses of 4 corners. If you pass QQRadiusZero, the final image will not add corner
  51. 4个圆角的半径,如果传入QQRadiusZero,最终的图片将不添加圆角
  52. */
  53. + (UIImage *)imageWithGradualChangingColor:(void(^)(QQGradualChangingColor *graColor))handler size:(CGSize)size cornerRadius:(QQRadius)radius;
  54. /**
  55. Create a UIImage with border and corner. Always uses in UIButton
  56. 创建一个边框图片,可以带圆角。通常在UIButton使用
  57. @param corner The properities of corner, see QQCorner.
  58. corner的属性,看QQCorner的介绍
  59. @param size The size of the image.
  60. 图片的尺寸
  61. */
  62. + (UIImage *)imageWithQQCorner:(void(^)(QQCorner *corner))handler size:(CGSize)size;
  63. @end