YOUPAILZLiveProtocolWindow.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // YOUPAILZLiveProtocolWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/7/28.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveProtocolWindow.h"
  9. #import <WebKit/WebKit.h>
  10. @interface YOUPAILZLiveProtocolWindow ()<WKUIDelegate,WKNavigationDelegate>
  11. @end
  12. @implementation YOUPAILZLiveProtocolWindow
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.baseView.hidden = YES;
  16. [self youpaifinitUI];
  17. }
  18. - (void)youpaifinitUI{
  19. UIView *bgV = [[UIView alloc] init];
  20. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  21. bgV.layer.cornerRadius = 10.0f;
  22. bgV.clipsToBounds = YES;
  23. [self.view addSubview:bgV];
  24. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.offset(32.0f);
  26. make.right.offset(-32.0f);
  27. make.centerY.equalTo(self.view);
  28. }];
  29. UILabel *titleL = [[UILabel alloc] init];
  30. titleL.font = LCFont(19.0f);
  31. titleL.textColor = [UIColor whiteColor];
  32. titleL.textAlignment = NSTextAlignmentCenter;
  33. titleL.text = @"直播管理条例";
  34. [bgV addSubview:titleL];
  35. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.offset(20.0f);
  37. make.left.offset(14.0f);
  38. make.right.offset(-14.0f);
  39. }];
  40. //创建网页配置对象
  41. WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
  42. WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
  43. webView.backgroundColor = HexColorFromRGB(0x2A2935);
  44. webView.UIDelegate = self;
  45. // 导航代理
  46. webView.navigationDelegate = self;
  47. webView.allowsBackForwardNavigationGestures = NO;
  48. NSString *protocolAddress = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,LiveProtocolH5];
  49. [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:protocolAddress]]];
  50. [bgV addSubview:webView];
  51. [webView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.offset(14.0f);
  53. make.right.offset(-14.0f);
  54. make.top.equalTo(titleL.mas_bottom).offset(20.0f);
  55. make.height.offset(263.0f);
  56. }];
  57. CGFloat width = (KScreenWidth-90.0f-15.0f) / 2.0f;
  58. UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  59. cancelBtn.layer.cornerRadius = 5.0f;
  60. cancelBtn.clipsToBounds = YES;
  61. cancelBtn.backgroundColor = HexColorFromRGB(0x9F9DA5);
  62. [cancelBtn setTitle:@"不同意" forState:UIControlStateNormal];
  63. [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  64. cancelBtn.titleLabel.font = LCFont17;
  65. [cancelBtn addTarget:self action:@selector(youpaifcancelBtnClick) forControlEvents:UIControlEventTouchUpInside];
  66. [bgV addSubview:cancelBtn];
  67. [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.offset(14.0f);
  69. make.top.equalTo(webView.mas_bottom).offset(20.0f);
  70. make.size.mas_offset(CGSizeMake(width, 48.0f));
  71. make.bottom.offset(-20.0f);
  72. }];
  73. UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  74. confirmBtn.layer.cornerRadius = 5.0f;
  75. confirmBtn.clipsToBounds = YES;
  76. [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(width, 48.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  77. [confirmBtn setTitle:@"开启直播" forState:UIControlStateNormal];
  78. [confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  79. confirmBtn.titleLabel.font = LCFont17;
  80. [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
  81. [bgV addSubview:confirmBtn];
  82. [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.right.offset(-14.0f);
  84. make.size.mas_offset(CGSizeMake(width, 48.0f));
  85. make.bottom.offset(-20.0f);
  86. }];
  87. }
  88. - (void)youpaifcancelBtnClick{
  89. [self dismissViewControllerAnimated:YES completion:^{
  90. if (self.youpaipagreeStartLiveBlock != nil) {
  91. self.youpaipagreeStartLiveBlock(NO);
  92. }
  93. }];
  94. }
  95. - (void)youpaifconfirmBtnClick{
  96. [self dismissViewControllerAnimated:YES completion:^{
  97. if (self.youpaipagreeStartLiveBlock != nil) {
  98. self.youpaipagreeStartLiveBlock(YES);
  99. }
  100. }];
  101. }
  102. @end