YMCaptchaTextCellProperty.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // YMCaptchaTextCellProperty.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2023/5/5.
  6. //
  7. #import "YMCaptchaTextCellProperty.h"
  8. @interface YMCaptchaTextCellProperty ()
  9. @property (nonatomic, copy, readwrite) NSString *originValue;
  10. @end
  11. @implementation YMCaptchaTextCellProperty
  12. - (instancetype)init{
  13. if (self = [super init]) {
  14. __weak typeof(self) weakSelf = self;
  15. // UI
  16. self.borderWidth = (0.5);
  17. self.cellBorderColorNormal = [UIColor colorWithRed:228/255.0 green:228/255.0 blue:228/255.0 alpha:1];
  18. self.cellBorderColorSelected = [UIColor colorWithRed:255/255.0 green:70/255.0 blue:62/255.0 alpha:1];
  19. self.cellBorderColorFilled = nil;
  20. self.cellBgColorNormal = [UIColor whiteColor];
  21. self.cellBgColorSelected = [UIColor whiteColor];
  22. self.cellBgColorFilled = nil;
  23. self.cellCursorColor = [UIColor colorWithRed:255/255.0 green:70/255.0 blue:62/255.0 alpha:1];
  24. self.cellCursorWidth = 2;
  25. self.cellCursorHeight = 32;
  26. self.cornerRadius = 4;
  27. // line
  28. self.showLine = NO;
  29. // label
  30. self.cellFont = [UIFont systemFontOfSize:20];
  31. self.cellTextColor = [UIColor blackColor];
  32. // Security
  33. self.ifShowSecurity = NO;
  34. self.securitySymbol = @"✱";
  35. self.originValue = @"";
  36. self.securityType = YMCaptchaTextSecuritySymbolType;
  37. // Placeholder
  38. self.cellPlaceholderText = nil;
  39. self.cellPlaceholderTextColor = [UIColor colorWithRed:114/255.0 green:116/255.0 blue:124/255.0 alpha:0.3];
  40. self.cellPlaceholderFont = [UIFont systemFontOfSize:20];
  41. // Block
  42. self.customSecurityViewBlock = ^UIView * _Nonnull{
  43. return [weakSelf defaultCustomSecurityView];
  44. };
  45. self.customLineViewBlock = ^YMCaptchaTextLineView * _Nonnull{
  46. return [YMCaptchaTextLineView new];
  47. };
  48. self.configCellShadowBlock = nil;
  49. // Test
  50. self.index = 0;
  51. }
  52. return self;
  53. }
  54. #pragma mark - Copy
  55. - (id)copyWithZone:(NSZone *)zone{
  56. YMCaptchaTextCellProperty *copy = [[self class] allocWithZone:zone];
  57. // UI
  58. copy.borderWidth = _borderWidth;
  59. copy.cellBorderColorNormal = [_cellBorderColorNormal copy];
  60. copy.cellBorderColorSelected = [_cellBorderColorSelected copy];
  61. if (_cellBorderColorFilled) {
  62. copy.cellBorderColorFilled = [_cellBorderColorFilled copy];
  63. }
  64. copy.cellBgColorNormal = [_cellBgColorNormal copy];
  65. copy.cellBgColorSelected = [_cellBgColorSelected copy];
  66. if (_cellBgColorFilled) {
  67. copy.cellBgColorFilled = [_cellBgColorFilled copy];
  68. }
  69. copy.cellCursorColor = [_cellCursorColor copy];
  70. copy.cellCursorWidth = _cellCursorWidth;
  71. copy.cellCursorHeight = _cellCursorHeight;
  72. copy.cornerRadius = _cornerRadius;
  73. // line
  74. copy.showLine = _showLine;
  75. // label
  76. copy.cellFont = [_cellFont copy];
  77. copy.cellTextColor = [_cellTextColor copy];
  78. // Security
  79. copy.ifShowSecurity = _ifShowSecurity;
  80. copy.securitySymbol = [_securitySymbol copy];
  81. copy.originValue = [_originValue copy];
  82. copy.securityType = _securityType;
  83. // Placeholder
  84. if (_cellPlaceholderText) {
  85. copy.cellPlaceholderText = [_cellPlaceholderText copy];
  86. }
  87. copy.cellPlaceholderTextColor = [_cellPlaceholderTextColor copy];
  88. copy.cellPlaceholderFont = [_cellPlaceholderFont copy];
  89. // Block
  90. copy.customSecurityViewBlock = [_customSecurityViewBlock copy];
  91. copy.customLineViewBlock = [_customLineViewBlock copy];
  92. if (_configCellShadowBlock) {
  93. copy.configCellShadowBlock = [_configCellShadowBlock copy];
  94. }
  95. // Test
  96. copy.index = _index;
  97. return copy;
  98. }
  99. #pragma mark - Getter
  100. - (UIView *)defaultCustomSecurityView
  101. {
  102. UIView *customSecurityView = [UIView new];
  103. customSecurityView.backgroundColor = [UIColor clearColor];
  104. // circleView
  105. static CGFloat circleViewWidth = 20;
  106. UIView *circleView = [UIView new];
  107. circleView.backgroundColor = [UIColor blackColor];
  108. circleView.layer.cornerRadius = 4;
  109. [customSecurityView addSubview:circleView];
  110. [circleView mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.width.height.mas_equalTo(circleViewWidth);
  112. make.centerX.offset(0);
  113. make.centerY.offset(0);
  114. }];
  115. return customSecurityView;
  116. }
  117. #pragma mark - Setter
  118. - (void)setMyOriginValue:(NSString *)originValue {
  119. _originValue = originValue;
  120. }
  121. @end