UserInputCell.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // UserInputCell.m
  3. // XWorld
  4. //
  5. // Created by dinglin on 2017/1/12.
  6. // Copyright © 2017年 xiongmaitech. All rights reserved.
  7. //
  8. #import "UserInputCell.h"
  9. #import <Masonry/Masonry.h>
  10. @implementation UserInputCell
  11. #pragma mark - lazyload
  12. -(UILabel *)customTitle {
  13. if (!_customTitle) {
  14. _customTitle = [[UILabel alloc] init];
  15. _customTitle.textColor = [UIColor blackColor];
  16. _customTitle.font = [UIFont systemFontOfSize:12 weight:UIFontWeightLight];
  17. }
  18. return _customTitle;
  19. }
  20. -(UITextField *)inputTextField {
  21. if (!_inputTextField) {
  22. _inputTextField = [[UITextField alloc] init];
  23. _inputTextField.textColor = [UIColor blackColor];
  24. }
  25. return _inputTextField;
  26. }
  27. -(UIButton *)toggleBtn {
  28. if (!_toggleBtn) {
  29. _toggleBtn = [[UIButton alloc] init];
  30. [_toggleBtn setImage:[UIImage imageNamed:@"icon_hide_nor.png"] forState:UIControlStateNormal];
  31. [_toggleBtn setImage:[UIImage imageNamed:@"icon_hide_sel.png"] forState:UIControlStateSelected];
  32. }
  33. return _toggleBtn;
  34. }
  35. #pragma mark -设置坐标
  36. -(void)makeUI {
  37. [self.contentView addSubview:self.customTitle];
  38. [self.contentView addSubview:self.inputTextField];
  39. [self.contentView addSubview:self.toggleBtn];
  40. [self.toggleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.right.equalTo(self.contentView).offset(-10);
  42. make.width.equalTo(@30);
  43. make.height.equalTo(@30);
  44. make.centerY.equalTo(self.contentView);
  45. }];
  46. [self.customTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.equalTo(self.contentView).offset(10);
  48. make.width.equalTo(@70);
  49. make.centerY.equalTo(self.contentView);
  50. make.height.equalTo(@30);
  51. }];
  52. [self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.right.equalTo(self.toggleBtn.mas_left).offset(-5);
  54. make.left.equalTo(self.customTitle.mas_right).offset(6);
  55. make.centerY.equalTo(self.contentView);
  56. }];
  57. }
  58. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  59. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  60. if (self) {
  61. [self makeUI];
  62. }
  63. return self;
  64. }
  65. @end