QQCornerModel.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // QQCornerModel.h
  3. // QQCorner
  4. //
  5. // Created by 秦琦 on 2018/10/24.
  6. // Copyright © 2018 QinQi. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. struct QQRadius {
  10. CGFloat upLeft; //The radius of upLeft. 左上半径
  11. CGFloat upRight; //The radius of upRight. 右上半径
  12. CGFloat downLeft; //The radius of downLeft. 左下半径
  13. CGFloat downRight; //The radius of downRight. 右下半径
  14. };
  15. typedef struct QQRadius QQRadius;
  16. static QQRadius const QQRadiusZero = (QQRadius){0, 0, 0, 0};
  17. NS_INLINE bool QQRadiusIsEqual(QQRadius radius1, QQRadius radius2) {
  18. return radius1.upLeft == radius2.upLeft && radius1.upRight == radius2.upRight && radius1.downLeft == radius2.downLeft && radius1.downRight == radius2.downRight;
  19. }
  20. NS_INLINE QQRadius QQRadiusMake(CGFloat upLeft, CGFloat upRight, CGFloat downLeft, CGFloat downRight) {
  21. QQRadius radius;
  22. radius.upLeft = upLeft;
  23. radius.upRight = upRight;
  24. radius.downLeft = downLeft;
  25. radius.downRight = downRight;
  26. return radius;
  27. }
  28. NS_INLINE QQRadius QQRadiusMakeSame(CGFloat radius) {
  29. QQRadius result;
  30. result.upLeft = radius;
  31. result.upRight = radius;
  32. result.downLeft = radius;
  33. result.downRight = radius;
  34. return result;
  35. }
  36. typedef NS_ENUM(NSUInteger, QQGradualChangeType) {
  37. QQGradualChangeTypeUpLeftToDownRight = 0,
  38. QQGradualChangeTypeUpToDown,
  39. QQGradualChangeTypeLeftToRight,
  40. QQGradualChangeTypeUpRightToDownLeft
  41. };
  42. typedef NS_OPTIONS(NSInteger, QQBorderPosition) {
  43. QQBorderPositionAll = 0,
  44. QQBorderPositionTop = 1 << 0,
  45. QQBorderPositionLeft = 1 << 1,
  46. QQBorderPositionBottom = 1 << 2,
  47. QQBorderPositionRight = 1 << 3,
  48. };
  49. @interface QQGradualChangingColor : NSObject
  50. @property (nonatomic, strong) UIColor *fromColor;
  51. @property (nonatomic, strong) UIColor *toColor;
  52. @property (nonatomic, assign) QQGradualChangeType type;
  53. @end
  54. @interface QQCorner : NSObject
  55. /**The frame of corners. 内部圆角的frame*/
  56. @property (nonatomic, assign) CGRect frame;
  57. /**The radiuses of 4 corners. 4个圆角的半径*/
  58. @property (nonatomic, assign) QQRadius radius;
  59. /**The color that will fill the layer/view. 将要填充layer/view的颜色*/
  60. @property (nonatomic, strong) UIColor *fillColor;
  61. /**The color of the border. 边框颜色*/
  62. @property (nonatomic, strong) UIColor *borderColor;
  63. /**The lineWidth of the border. 边框宽度*/
  64. @property (nonatomic, assign) CGFloat borderWidth;
  65. /// 边框位置
  66. @property (nonatomic, assign) QQBorderPosition borderPosition;
  67. @property(nonatomic, strong, readwrite) CAShapeLayer *qq_CurrentLayer;
  68. @end