TableWithVerificationCodeCell.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // TableWithVerificationCodeCell.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/16.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 带获取验证码的cell
  8. #import "TableWithVerificationCodeCell.h"
  9. #import <objc/runtime.h>
  10. @implementation TableWithVerificationCodeCell
  11. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  12. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. self.selectionStyle = UITableViewCellSelectionStyleNone;
  15. self.backgroundColor = [UIColor whiteColor];
  16. [self setUpSubViewsForCell];
  17. }
  18. return self;
  19. }
  20. - (void)setUpSubViewsForCell {
  21. CGFloat cellHeight = 50;
  22. UILabel *titleLabel = [[UILabel alloc] init];
  23. titleLabel.frame = CGRectMake(20, 0, 80, cellHeight);
  24. titleLabel.textAlignment = NSTextAlignmentLeft;
  25. titleLabel.font = [UIFont systemFontOfSize:16];
  26. titleLabel.textColor = RGBValueColor(0x333333, 1.0);
  27. [self.contentView addSubview:titleLabel];
  28. self.titleLabel = titleLabel;
  29. //
  30. UITextField *contentTF = [[UITextField alloc] init];
  31. contentTF.frame = CGRectMake(CGRectGetMaxX(titleLabel.frame), 0, ScreenWidth - 200, cellHeight);
  32. contentTF.textAlignment = NSTextAlignmentLeft;
  33. contentTF.font = [UIFont systemFontOfSize:16];
  34. contentTF.textColor = RGBValueColor(0x333333, 1.0);
  35. Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
  36. UILabel *placeholderLabel = object_getIvar(contentTF, ivar);
  37. placeholderLabel.textColor = RGBValueColor(0x999999, 1.0);
  38. contentTF.clearButtonMode = UITextFieldViewModeWhileEditing;
  39. [self.contentView addSubview:contentTF];
  40. self.contentTF = contentTF;
  41. //
  42. UIButton *codeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. codeBtn.frame = CGRectMake(ScreenWidth - 120, cellHeight / 2 - 16, 100, 32);
  44. codeBtn.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  45. [codeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  46. [codeBtn setTitleColor:RGBValueColor(0xfe4086, 1.0) forState:UIControlStateNormal];
  47. codeBtn.titleLabel.font = [UIFont systemFontOfSize:16.0];
  48. codeBtn.layer.cornerRadius = 16;
  49. codeBtn.layer.masksToBounds = YES;
  50. [self.contentView addSubview:codeBtn];
  51. self.codeBtn = codeBtn;
  52. }
  53. @end