BogoYounthModePopView.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // BogoYounthModePopView.m
  3. // AFNetworking
  4. //
  5. // Created by 宋晨光 on 2021/9/11.
  6. //
  7. #import "BogoYounthModePopView.h"
  8. @implementation BogoYounthModePopView
  9. - (instancetype)initWithFrame:(CGRect)frame
  10. {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.backgroundColor = kClearColor;
  14. [self setUpView];
  15. }
  16. return self;
  17. }
  18. -(void)setUpView{
  19. self.bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kRealValue(290), self.height)];
  20. self.bgView.backgroundColor = kWhiteColor;
  21. self.bgView.layer.cornerRadius = 10;
  22. self.bgView.layer.masksToBounds = YES;
  23. self.topImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, kRealValue(104), kRealValue(100))];
  24. self.topImgView.centerX = self.width / 2;
  25. self.topImgView.image = [UIImage imageNamed:@"bogo_youth_TopImage"];
  26. self.titleL = [[UILabel alloc]initWithFrame:CGRectMake(0, self.topImgView.bottom, self.bgView.width - kRealValue(15 * 2), kRealValue(20))];
  27. self.titleL.text = ASLocalizedString(@"青少年模式");
  28. self.titleL.textAlignment = NSTextAlignmentCenter;
  29. self.titleL.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  30. self.contentL.frame = CGRectMake(kRealValue(15), self.topImgView.bottom + kRealValue(10), self.bgView.width - kRealValue(15 * 2), kRealValue(self.bgView.height - self.topImgView.bottom - kRealValue(10) - kRealValue(123)));
  31. self.confirmBtn.frame = CGRectMake(0, self.height - kRealValue(10) - kRealValue(40), kRealValue(180), kRealValue(40));
  32. self.inYounthBtn.frame = CGRectMake(kRealValue(15), self.confirmBtn.top - kRealValue(10) - kRealValue(20), self.width, kRealValue(20));
  33. self.titleL.centerX = self.contentL.centerX = self.topImgView.centerX = self.confirmBtn.centerX = self.inYounthBtn.centerX = self.bgView.width / 2;
  34. self.bgView.centerX = self.width / 2;
  35. [self addSubview:self.bgView];
  36. [self.bgView addSubview:self.topImgView];
  37. [self addSubview:self.titleL];
  38. self.titleL.hidden = YES;
  39. [self.bgView addSubview:self.contentL];
  40. [self.bgView addSubview:self.inYounthBtn];
  41. [self.bgView addSubview:self.confirmBtn];
  42. }
  43. -(void)clickInYountBtn:(UIButton *)sender{
  44. if (self.clickInYounthBlock) {
  45. self.clickInYounthBlock(YES);
  46. }
  47. }
  48. -(void)clickConfirmBtn:(UIButton *)sender{
  49. [GlobalVariables sharedInstance].isShutDownYoung = NO;
  50. [self hide];
  51. }
  52. -(UILabel *)contentL{
  53. if (!_contentL) {
  54. _contentL = [UILabel new];
  55. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  56. paragraphStyle.lineSpacing = 2; //设置行间距
  57. paragraphStyle.lineBreakMode = _contentL.lineBreakMode;
  58. paragraphStyle.alignment = NSTextAlignmentLeft;
  59. NSString *content = ASLocalizedString(@"为呵护未成年人健康成长,711Live特别推出青少年模式,该模式下部分功能无法正常使用。请监护人主动选择,并设置监护密码。");
  60. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:content];
  61. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14.0],
  62. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"777777"],
  63. NSParagraphStyleAttributeName:paragraphStyle};
  64. [attributedString setAttributes:attributes range:NSMakeRange(0, attributedString.length)];
  65. _contentL.attributedText = attributedString;
  66. _contentL.numberOfLines = 0;
  67. }
  68. return _contentL;
  69. }
  70. -(UIButton *)inYounthBtn{
  71. if (!_inYounthBtn) {
  72. _inYounthBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  73. [_inYounthBtn setTitle:ASLocalizedString(@"开启青少年模式") forState:UIControlStateNormal];
  74. [_inYounthBtn setTitleColor:[UIColor colorWithHexString:@"#30B3FF"] forState:UIControlStateNormal];
  75. _inYounthBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  76. [_inYounthBtn addTarget:self action:@selector(clickInYountBtn:) forControlEvents:UIControlEventTouchUpInside];
  77. }
  78. return _inYounthBtn;
  79. }
  80. -(UIButton *)confirmBtn{
  81. if (!_confirmBtn) {
  82. _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  83. [_confirmBtn setTitle:ASLocalizedString(@"我知道了") forState:UIControlStateNormal];
  84. _confirmBtn.titleLabel.font = [UIFont boldSystemFontOfSize:21];
  85. [_confirmBtn setBackgroundImage:[UIImage imageNamed:@"bogo_youth_confirmBtn"] forState:UIControlStateNormal];
  86. [_confirmBtn addTarget:self action:@selector(clickConfirmBtn:) forControlEvents:UIControlEventTouchUpInside];
  87. }
  88. return _confirmBtn;
  89. }
  90. @end