TableDefaultCell.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // TableDefaultCell.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/16.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 标题 + 内容 cell
  8. #import "TableDefaultCell.h"
  9. #import <objc/runtime.h>
  10. @implementation TableDefaultCell
  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 - 121, 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. self.lineView = [[UIImageView alloc] initWithFrame:CGRectMake(0, cellHeight - 1, ScreenWidth, 1)];
  43. self.lineView.image = [UIImage imageNamed:@"fengexian"];
  44. [self.contentView addSubview:self.lineView];
  45. }
  46. @end