WXHCodeViewDefaultItem.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // WXHCodeViewDefaultItem.m
  3. // xh_textfield
  4. //
  5. // Created by 路 on 2019/10/24.
  6. // Copyright © 2019年 路. All rights reserved.
  7. //
  8. #import "WXHCodeViewDefaultItem.h"
  9. @interface WXHCodeViewDefaultItem ()
  10. @property (strong ,nonatomic) UIView *line;
  11. @end
  12. @implementation WXHCodeViewDefaultItem
  13. - (id)init; {
  14. self = [super init];
  15. if (self) {
  16. _lineNormalColor = [UIColor grayColor];
  17. _lineActivatedColor = [UIColor redColor];
  18. _label = [[UILabel alloc] init];
  19. _label.font = [UIFont boldSystemFontOfSize:20];
  20. _label.textColor = [UIColor blackColor];
  21. _label.textAlignment = NSTextAlignmentCenter;
  22. [self addSubview:_label];
  23. _line = [[UIView alloc] init];
  24. [self addSubview:_line];
  25. } return self;
  26. }
  27. - (void)layoutSubviews; {
  28. [super layoutSubviews];
  29. _label.frame = self.bounds;
  30. _line.frame = CGRectMake(0, self.frame.size.height - 1.f, self.frame.size.width, 1.f);
  31. }
  32. - (void)setText:(NSString *)text; {
  33. [super setText:text];
  34. _label.text = text;
  35. }
  36. - (void)setActivated:(BOOL)activated; {
  37. [super setActivated:activated];
  38. if (activated) {
  39. _line.backgroundColor = _lineActivatedColor;
  40. } else {
  41. _line.backgroundColor = _lineNormalColor;
  42. }
  43. }
  44. @end