YBYoungSmall.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // YBYoungSmall.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2022/6/2.
  6. // Copyright © 2022 cat. All rights reserved.
  7. //
  8. #import "YBYoungSmall.h"
  9. @interface YBYoungSmall()
  10. @property(nonatomic,strong)NSString *alertStr;
  11. @property(nonatomic,strong)UIView *bgView;
  12. @end
  13. @implementation YBYoungSmall
  14. +(instancetype)showYoungPop:(NSString *)alert;{
  15. YBYoungSmall *view = [[YBYoungSmall alloc]init];
  16. view.frame = CGRectMake(0, 0, _window_width, _window_height);
  17. view.alertStr = alert;
  18. [view createUI];
  19. [[UIApplication sharedApplication].delegate.window addSubview:view];
  20. [PublicObj layoutWindowPopLayer];
  21. return view;
  22. }
  23. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch; {
  24. if ([touch.view isDescendantOfView:self.bgView]) {
  25. return NO;
  26. }
  27. return YES;
  28. }
  29. -(void)dissmissView {
  30. [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  31. [self removeFromSuperview];
  32. }
  33. -(void)createUI {
  34. /*
  35. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dissmissView)];
  36. tap.delegate = self;
  37. [self addGestureRecognizer:tap];
  38. */
  39. self.backgroundColor = ybPopBgCol;
  40. _bgView = [[UIView alloc]init];
  41. _bgView.backgroundColor = UIColor.whiteColor;
  42. _bgView.layer.cornerRadius = 10;
  43. _bgView.layer.masksToBounds = YES;
  44. [self addSubview:_bgView];
  45. [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerX.width.bottom.equalTo(self);
  47. }];
  48. //
  49. UIImageView *topIV = [[UIImageView alloc]init];
  50. topIV.image = [UIImage imageNamed:@"青少年-小窗"];
  51. [_bgView addSubview:topIV];
  52. [topIV mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.height.mas_equalTo(70);
  54. make.width.equalTo(topIV.mas_height).multipliedBy(359.0/177);
  55. make.top.equalTo(_bgView.mas_top).offset(20);
  56. make.centerX.equalTo(_bgView);
  57. }];
  58. //
  59. UILabel *contentL = [[UILabel alloc]init];
  60. contentL.font = SYS_Font(15);
  61. contentL.text = _alertStr;
  62. contentL.textColor = RGB_COLOR(@"#323232", 1);
  63. contentL.numberOfLines = 0;
  64. [_bgView addSubview:contentL];
  65. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.width.equalTo(_bgView.mas_width).offset(-40);
  67. make.top.equalTo(topIV.mas_bottom).offset(20);
  68. make.centerX.equalTo(_bgView);
  69. }];
  70. //
  71. UIButton *enterYoungBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  72. [enterYoungBtn setTitle:YZMsg(@"进入青少年模式>") forState:0];
  73. enterYoungBtn.titleLabel.font = SYS_Font(15);
  74. [enterYoungBtn setTitleColor:Pink_Cor forState:0];
  75. [enterYoungBtn addTarget:self action:@selector(clickEnterBtn) forControlEvents:UIControlEventTouchUpInside];
  76. [_bgView addSubview:enterYoungBtn];
  77. [enterYoungBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.centerX.equalTo(_bgView);
  79. make.top.equalTo(contentL.mas_bottom).offset(10);
  80. }];
  81. //
  82. UIButton *knowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  83. [knowBtn setTitle:YZMsg(@"我知道了") forState:0];
  84. knowBtn.titleLabel.font = SYS_Font(15);
  85. [knowBtn setTitleColor:UIColor.whiteColor forState:0];
  86. [knowBtn addTarget:self action:@selector(clickKnowBtn) forControlEvents:UIControlEventTouchUpInside];
  87. knowBtn.layer.cornerRadius = 22;
  88. knowBtn.layer.masksToBounds = YES;
  89. knowBtn.backgroundColor = Pink_Cor;
  90. [_bgView addSubview:knowBtn];
  91. [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.width.equalTo(_bgView.mas_width).multipliedBy(0.7);
  93. make.height.mas_equalTo(44);
  94. make.centerX.equalTo(_bgView);
  95. make.top.equalTo(enterYoungBtn.mas_bottom).offset(20);
  96. make.bottom.equalTo(_bgView.mas_bottom).offset(-25-ShowDiff);
  97. }];
  98. [_bgView layoutIfNeeded];
  99. [_bgView jk_setRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:10];
  100. }
  101. -(void)clickEnterBtn {
  102. [[YBYoungManager shareInstance] smallEnterYoungModel];
  103. }
  104. -(void)clickKnowBtn {
  105. [[YBYoungManager shareInstance] destroySamllPop];
  106. }
  107. @end