NewPeopleWelfareViewController.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // NewPeopleWelfareViewController.m
  3. // 隐私保护
  4. //
  5. // Created by APPLE on 2023/8/30.
  6. //
  7. #import "NewPeopleWelfareViewController.h"
  8. #import <Masonry.h>
  9. @interface NewPeopleWelfareViewController ()
  10. @end
  11. @implementation NewPeopleWelfareViewController
  12. @synthesize delegate;
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. [self drawAnyView];
  17. }
  18. - (void)drawAnyView{
  19. [self.view setBackgroundColor:HW000000Color60];
  20. [self.toolBar setHidden:YES];
  21. [self.navigationBar setHidden:YES];
  22. UIImageView *alertBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"new_people_welfare_bg"]];
  23. [alertBg setUserInteractionEnabled:YES];
  24. [self.view addSubview:alertBg];
  25. [alertBg mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerY.equalTo(self.view.mas_centerY).offset(-30*HAUTOSCALE);
  27. make.centerX.equalTo(self.view.mas_centerX);
  28. make.width.mas_equalTo(324);
  29. make.height.mas_equalTo(323);
  30. }];
  31. /*新人福利*/
  32. UILabel *topLabel = [[UILabel alloc] init];
  33. [topLabel setText:NSLocalizedString(@"new_people_welfare_title",nil)];
  34. [topLabel setTextColor:HW0458E3Color];
  35. [topLabel setFont:[UIFont boldSystemFontOfSize:26.f]];
  36. [alertBg addSubview:topLabel];
  37. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.mas_equalTo(41.f);
  39. make.left.mas_equalTo(40.f);
  40. }];
  41. NSInteger welfareDay = 3;
  42. NSString *leftStr = @"赠送您";
  43. NSString *medileStr = @"三天";
  44. NSString *rightStr = @"的试用会员";
  45. UILabel *detaileLabel = [[UILabel alloc] init];
  46. [detaileLabel setFont:[UIFont boldSystemFontOfSize:12]];
  47. [alertBg addSubview:detaileLabel];
  48. [detaileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.mas_equalTo(76.f);
  50. make.left.mas_equalTo(40.f);
  51. }];
  52. NSString *showStr = [[leftStr stringByAppendingString:medileStr] stringByAppendingString:rightStr];
  53. NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:showStr attributes: @{NSForegroundColorAttributeName:HW2F3972Color}];
  54. [string addAttributes:@{NSForegroundColorAttributeName:HWDD4E4EColor} range:NSMakeRange(leftStr.length, medileStr.length)];
  55. [detaileLabel setAttributedText:string];
  56. UIImageView *alertMiddleBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"new_people_welfare_middle_bg"]];
  57. [alertBg addSubview:alertMiddleBg];
  58. [alertMiddleBg mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.mas_equalTo(120.f);
  60. make.centerX.equalTo(alertBg.mas_centerX);
  61. make.width.mas_equalTo(240);
  62. make.height.mas_equalTo(33);
  63. }];
  64. /*会员特权*/
  65. UILabel *middleTopLabel = [[UILabel alloc] init];
  66. [middleTopLabel setTextColor:HWFFFFFFColor];
  67. [middleTopLabel setFont:[UIFont systemFontOfSize:12.f]];
  68. [middleTopLabel setTextAlignment:(NSTextAlignmentCenter)];
  69. [alertBg addSubview:middleTopLabel];
  70. [middleTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.mas_equalTo(126.f);
  72. make.centerX.equalTo(alertBg.mas_centerX);
  73. }];
  74. [middleTopLabel setText:NSLocalizedString(@"buy_home_fun_title",nil)];
  75. /*功能列表*/
  76. NSArray *titleAry = @[@"11111",@"22222",@"33333",@"444444",@"5555",@"66666"];
  77. for (NSInteger nFori = 0; nFori < titleAry.count; nFori++) {
  78. UIButton *flagBtn = [[UIButton alloc] init];
  79. [flagBtn setImage:[UIImage imageNamed:@"buy_home_flag_fun"] forState:(UIControlStateNormal)];
  80. [flagBtn setTitleColor:HW666666Color forState:(UIControlStateNormal)];
  81. [flagBtn.titleLabel setFont:[UIFont systemFontOfSize:12.f]];
  82. [flagBtn setTitle:[titleAry objectAtIndex:nFori] forState:(UIControlStateNormal)];
  83. [flagBtn setContentHorizontalAlignment:(UIControlContentHorizontalAlignmentLeft)];
  84. [alertBg addSubview:flagBtn];
  85. /*计算位置*/
  86. NSInteger x_place = nFori%2;
  87. NSInteger y_palce = nFori/2;
  88. [flagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89. if (x_place == 0){
  90. make.left.mas_equalTo(55.f);
  91. }else{
  92. make.left.equalTo(alertBg.mas_centerX).offset(10);
  93. }
  94. make.width.mas_equalTo(140);
  95. make.top.mas_equalTo(157 + y_palce*(18.f+8.f));
  96. make.height.mas_equalTo(18);
  97. }];
  98. }
  99. /*开始体验按钮*/
  100. UIButton *downBtn = [[UIButton alloc] init];
  101. downBtn.frame = CGRectMake(0, 0, 184.f, 36.f);
  102. // gradient
  103. CAGradientLayer *gl = [CAGradientLayer layer];
  104. gl.frame = CGRectMake(0,0,184.f,36.f);
  105. gl.startPoint = CGPointMake(0, 0.5);
  106. gl.endPoint = CGPointMake(1, 0.5);
  107. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  108. gl.locations = @[@(0), @(1.0f)];
  109. [downBtn.layer addSublayer:gl];
  110. [downBtn addTarget:self action:@selector(downBtnBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  111. [downBtn setTitle:NSLocalizedString(@"new_people_welfare_start_use",nil) forState:(UIControlStateNormal)];
  112. [downBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  113. [downBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  114. [downBtn.layer setCornerRadius:8.f];
  115. downBtn.clipsToBounds = YES;
  116. [alertBg addSubview:downBtn];
  117. [downBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.centerX.equalTo(self.view.mas_centerX);
  119. make.width.mas_equalTo(184.f);
  120. make.bottom.mas_equalTo(-20.f);
  121. make.height.mas_equalTo(36.f);
  122. }];
  123. }
  124. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  125. [self dismissViewControllerAnimated:YES completion:^{
  126. ;
  127. }];
  128. }
  129. - (void)downBtnBtnClick{
  130. [self dismissViewControllerAnimated:YES completion:^{
  131. if ([self->delegate respondsToSelector:@selector(downBtnBtnClickPressed)]){
  132. [self->delegate downBtnBtnClickPressed];
  133. }
  134. }];
  135. }
  136. /*
  137. #pragma mark - Navigation
  138. // In a storyboard-based application, you will often want to do a little preparation before navigation
  139. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  140. // Get the new view controller using [segue destinationViewController].
  141. // Pass the selected object to the new view controller.
  142. }
  143. */
  144. @end