CellWithBtnView.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // CellWithBtnView.m
  3. // 隐私保护
  4. //
  5. // Created by APPLE on 2023/8/24.
  6. //
  7. #import "CellWithBtnView.h"
  8. #import <Masonry.h>
  9. @implementation CellWithBtnView
  10. @synthesize topLabel;
  11. @synthesize downLabel;
  12. @synthesize rightBtn;
  13. /*
  14. // Only override drawRect: if you perform custom drawing.
  15. // An empty implementation adversely affects performance during animation.
  16. - (void)drawRect:(CGRect)rect {
  17. // Drawing code
  18. }
  19. */
  20. - (id)initWithFrame:(CGRect)frame{
  21. self = [super initWithFrame:frame];
  22. [self drawAnyView];
  23. return self;
  24. }
  25. - (void)drawAnyView{
  26. topLabel = [[UILabel alloc] init];
  27. [topLabel setTextColor:HW0A132BColor];
  28. [topLabel setFont:[UIFont boldSystemFontOfSize:16]];
  29. [topLabel setText:@"111111111"];
  30. [self addSubview:topLabel];
  31. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(24.f);
  33. make.top.mas_equalTo(16.f);
  34. make.right.mas_equalTo(-124.f);
  35. make.height.mas_equalTo(20.f);
  36. }];
  37. downLabel = [[UILabel alloc] init];
  38. [downLabel setTextColor:HW666666Color];
  39. [downLabel setFont:[UIFont systemFontOfSize:10]];
  40. [downLabel setText:@"222222222"];
  41. [self addSubview:downLabel];
  42. [downLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(24.f);
  44. make.bottom.mas_equalTo(-17.f);
  45. make.right.mas_equalTo(-124.f);
  46. }];
  47. /*右侧按钮*/
  48. rightBtn = [[UIButton alloc] init];
  49. rightBtn.frame = CGRectMake(0, 0, 84.f, 36.f);
  50. // gradient
  51. CAGradientLayer *gl = [CAGradientLayer layer];
  52. gl.frame = CGRectMake(0,0,84.f,36.f);
  53. gl.startPoint = CGPointMake(0, 0.5);
  54. gl.endPoint = CGPointMake(1, 0.5);
  55. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  56. gl.locations = @[@(0), @(1.0f)];
  57. [rightBtn.layer addSublayer:gl];
  58. [rightBtn setTitle:@"3333333333" forState:(UIControlStateNormal)];
  59. [rightBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  60. [rightBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:12.f]];
  61. [rightBtn.layer setCornerRadius:18.f];
  62. rightBtn.clipsToBounds = YES;
  63. [self addSubview:rightBtn];
  64. [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.centerY.equalTo(self.mas_centerY);
  66. make.width.mas_equalTo(84);
  67. make.right.mas_equalTo(-8.f);
  68. make.height.mas_equalTo(36);
  69. }];
  70. }
  71. @end