VIPFunctForBuyView.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // VIPFunctView.m
  3. // 隐私保护
  4. //
  5. // Created by APPLE on 2023/8/24.
  6. //
  7. #import "VIPFunctForBuyView.h"
  8. #import <Masonry.h>
  9. @interface VIPFunctForBuyView(){
  10. }
  11. @end
  12. @implementation VIPFunctForBuyView
  13. - (id)initWithFunAry:(NSArray *)titleAry{
  14. self = [super init];
  15. [self drawAnyViewWithAry:titleAry];
  16. return self;
  17. }
  18. - (void)drawAnyViewWithAry:(NSArray *)titleAry{
  19. /*上方文字*/
  20. UILabel *topLabel = [[UILabel alloc] init];
  21. [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  22. [topLabel setTextColor:HW0A132BColor];
  23. [topLabel setText:NSLocalizedString(@"buy_home_fun_title",nil)];
  24. [topLabel setTextAlignment:(NSTextAlignmentCenter)];
  25. [self addSubview:topLabel];
  26. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.mas_equalTo(0);
  28. make.right.mas_equalTo(0);
  29. make.top.mas_equalTo(10);
  30. make.height.mas_equalTo(22);
  31. }];
  32. CGFloat w_Line = 56.f*AUTOSCALE;
  33. CGFloat h_line = 2.f;
  34. UIView *lineLeft = [[UIButton alloc] init];
  35. lineLeft.frame = CGRectMake(0, 0, w_Line, 2.f);
  36. // gradient
  37. CAGradientLayer *gl = [CAGradientLayer layer];
  38. gl.frame = CGRectMake(0,0,w_Line,h_line);
  39. gl.startPoint = CGPointMake(0, 0.5);
  40. gl.endPoint = CGPointMake(1, 0.5);
  41. gl.colors = @[(__bridge id)HW0A132BColor00.CGColor, (__bridge id)HW182B56Color.CGColor];
  42. gl.locations = @[@(0), @(1.0f)];
  43. [lineLeft.layer addSublayer:gl];
  44. [self addSubview:lineLeft];
  45. [lineLeft mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerY.equalTo(topLabel.mas_centerY);
  47. make.right.equalTo(self.mas_centerX).offset(-82);
  48. make.width.mas_equalTo(w_Line);
  49. make.height.mas_equalTo(h_line);
  50. }];
  51. UIView *lineRight = [[UIButton alloc] init];
  52. lineRight.frame = CGRectMake(0, 0, w_Line, 2.f);
  53. // gradient
  54. CAGradientLayer *gl1 = [CAGradientLayer layer];
  55. gl1.frame = CGRectMake(0,0,w_Line,h_line);
  56. gl1.startPoint = CGPointMake(0, 0.5);
  57. gl1.endPoint = CGPointMake(1, 0.5);
  58. gl1.colors = @[(__bridge id)HW182B56Color.CGColor, (__bridge id)HW0A132BColor00.CGColor];
  59. gl1.locations = @[@(0), @(1.0f)];
  60. [lineRight.layer addSublayer:gl1];
  61. [self addSubview:lineRight];
  62. [lineRight mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerY.equalTo(topLabel.mas_centerY);
  64. make.left.equalTo(self.mas_centerX).offset(82);
  65. make.width.mas_equalTo(w_Line);
  66. make.height.mas_equalTo(h_line);
  67. }];
  68. /*绘制标签*/
  69. for (NSInteger nFori = 0; nFori < titleAry.count; nFori++) {
  70. UIButton *flagBtn = [[UIButton alloc] init];
  71. [flagBtn setImage:[UIImage imageNamed:@"buy_home_flag_fun"] forState:(UIControlStateNormal)];
  72. [flagBtn setTitleColor:HW666666Color forState:(UIControlStateNormal)];
  73. [flagBtn.titleLabel setFont:[UIFont systemFontOfSize:12.f]];
  74. [flagBtn setTitle:[titleAry objectAtIndex:nFori] forState:(UIControlStateNormal)];
  75. [flagBtn setContentHorizontalAlignment:(UIControlContentHorizontalAlignmentLeft)];
  76. [self addSubview:flagBtn];
  77. /*计算位置*/
  78. NSInteger x_place = nFori%2;
  79. NSInteger y_palce = nFori/2;
  80. [flagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  81. if (x_place == 0){
  82. make.left.mas_equalTo(28);
  83. }else{
  84. make.left.equalTo(self.mas_centerX).offset(28);
  85. }
  86. make.width.mas_equalTo(140);
  87. make.top.mas_equalTo(42 + y_palce*(18.f+8.f));
  88. make.height.mas_equalTo(18);
  89. }];
  90. }
  91. }
  92. /*
  93. // Only override drawRect: if you perform custom drawing.
  94. // An empty implementation adversely affects performance during animation.
  95. - (void)drawRect:(CGRect)rect {
  96. // Drawing code
  97. }
  98. */
  99. @end