YOUPAILCCommonSwitchCell.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // YOUPAILCCommonSwitchCell.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/8/26.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCommonSwitchCell.h"
  9. @implementation YOUPAILCCommonSwitchCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  12. self.selectionStyle = UITableViewCellSelectionStyleNone;
  13. //v.1.5.6适配暗黑模式
  14. [self.contentView setBackgroundColor:[UIColor whiteColor]];
  15. self.youpaipcanSwitch = YES;
  16. [self youpaifinitUI];
  17. }
  18. return self;
  19. }
  20. - (void)youpaifinitUI{
  21. // self.baseView = [[UIView alloc]initWithFrame:CGRectMake(16,0,KScreenWidth-32,45)];
  22. // self.baseView.backgroundColor = [UIColor whiteColor];
  23. // [self.contentView addSubview:self.baseView];
  24. self.youpaipline = [[UIView alloc]initWithFrame:CGRectMake(14,44.5,KScreenWidth-28,0.5)];
  25. self.youpaipline.backgroundColor = [UIColor whiteColor];
  26. [self.contentView addSubview:self.youpaipline];
  27. self.youpaipheadLabel = [[UILabel alloc]init];
  28. self.youpaipheadLabel.font = LCBoldFont(14.0f);
  29. self.youpaipheadLabel.textColor = LZ273145Color;
  30. self.youpaipheadLabel.textAlignment = NSTextAlignmentLeft;
  31. [self.contentView addSubview:self.youpaipheadLabel];
  32. [self.youpaipheadLabel makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.equalTo(self.mas_left).offset(19);
  34. make.top.equalTo(@14);
  35. make.height.equalTo(@17);
  36. }];
  37. self.youpaiprightBtn = [[UIButton alloc]init];
  38. self.youpaiprightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  39. // self.rightLabel.textColor = HexColorFromRGB(0xffffff);
  40. [self.contentView addSubview:self.youpaiprightBtn];
  41. [self.youpaiprightBtn makeConstraints:^(MASConstraintMaker *make) {
  42. make.right.mas_equalTo(-19);
  43. make.top.equalTo(@14);
  44. make.size.mas_equalTo(CGSizeMake(50, 20));
  45. }];
  46. self.youpaiprightBtn.titleLabel.textAlignment = NSTextAlignmentRight;
  47. self.youpaipcommonSwitch = [[UIButton alloc]init];
  48. // self.commonSwitch.backgroundColor = HexColorFromRGB(0xcccccc);
  49. // self.commonSwitch.layer.cornerRadius = 15;
  50. // self.commonSwitch.onTintColor = HexColorFromRGB(0x6CE980);
  51. [self.contentView addSubview:self.youpaipcommonSwitch];
  52. [self.youpaipcommonSwitch makeConstraints:^(MASConstraintMaker *make) {
  53. make.right.equalTo(self.mas_right).offset(-19);
  54. make.centerY.equalTo(self.contentView);
  55. make.size.mas_equalTo(CGSizeMake(40, 22));
  56. }];
  57. [self.youpaipcommonSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected];
  58. [self.youpaipcommonSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal];
  59. // self.commonSwitch.transform = CGAffineTransformMakeScale(39/self.commonSwitch.frame.size.width,24/self.commonSwitch.frame.size.height);
  60. // self.commonSwitch.centerY = 22.5;
  61. // self.commonSwitch.centerX = 26.5;
  62. }
  63. - (void)setYoupaipcanSwitch:(BOOL)canSwitch{
  64. _youpaipcanSwitch = canSwitch;
  65. if (canSwitch) {
  66. self.youpaipcommonSwitch.userInteractionEnabled = YES;
  67. self.youpaipcommonSwitch.alpha = 1.0;
  68. }else{
  69. self.youpaipcommonSwitch.userInteractionEnabled = NO;
  70. self.youpaipcommonSwitch.alpha = 0.5;
  71. }
  72. }
  73. @end