ChatSettingCell.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // ChatSettingCell.m
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/5/22.
  6. //
  7. #import "ChatSettingCell.h"
  8. @implementation ChatSettingCell
  9. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  10. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  11. self.selectionStyle = UITableViewCellSelectionStyleNone;
  12. self.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
  13. self.backgroundColor = UIColor.clearColor;
  14. [self configUI];
  15. }
  16. return self;
  17. }
  18. - (void)configUI{
  19. [self.contentView addSubview:self.titleLbl];
  20. [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.height.mas_equalTo(18);
  22. make.left.mas_equalTo(20);
  23. make.top.mas_equalTo(16);
  24. make.bottom.mas_equalTo(-16);
  25. }];
  26. [self.contentView addSubview:self.stateSwitch];
  27. [self.stateSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.size.mas_equalTo(CGSizeMake(50, 30));
  29. make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
  30. make.centerY.mas_equalTo(self.titleLbl.mas_centerY);
  31. }];
  32. }
  33. #pragma mark event
  34. - (void)stateSwitchChange:(UISwitch *)stateSwitch{
  35. !self.stateSwitchChangeValue?:self.stateSwitchChangeValue(stateSwitch.isOn);
  36. }
  37. #pragma mark lazy
  38. - (UILabel *)titleLbl{
  39. if (!_titleLbl) {
  40. _titleLbl = [[UILabel alloc] init];
  41. _titleLbl.textColor = UIColor.whiteColor;
  42. _titleLbl.font = SYSFONT(16);
  43. }
  44. return _titleLbl;
  45. }
  46. - (CustomSwitch *)stateSwitch{
  47. if (!_stateSwitch) {
  48. _stateSwitch = [[CustomSwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
  49. // _stateSwitch.onTintColor = [UIColor jk_colorWithHexString:@"#1EEC99"];
  50. // _stateSwitch.offBackgroundColor = [UIColor jk_colorWithHexString:@"#545966"];
  51. [_stateSwitch addTarget:self action:@selector(stateSwitchChange:) forControlEvents:UIControlEventValueChanged];
  52. }
  53. return _stateSwitch;
  54. }
  55. @end