This commit is contained in:
启星
2025-11-03 09:55:25 +08:00
parent 89c9dd0898
commit f0c82c3ac7
9 changed files with 232 additions and 58 deletions

View File

@@ -0,0 +1,97 @@
//
// QXDayTaskRuleView.m
// QXLive
//
// Created by on 2025/6/6.
//
#import "QXDayTaskRuleView.h"
#import <WebKit/WebKit.h>
static void *WKWebBrowserContext = &WKWebBrowserContext;
@interface QXDayTaskRuleView()<WKNavigationDelegate,WKUIDelegate>
@property(nonatomic,strong)WKWebView *contentWebView;
@property(nonatomic,strong)UIButton* closeBtn;
@end
@implementation QXDayTaskRuleView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
[self addSubview:self.contentWebView];
[self loadData];
self.closeBtn = [[UIButton alloc] initWithFrame:CGRectMake((self.width-30)/2, self.contentWebView.bottom+10, 30, 30)];
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.closeBtn];
}
-(void)closeAction{
[self removeFromSuperview];
}
- (void)loadData {
NSString *urlStr = [NSString stringWithFormat:@"%@web/index.html#/pages/other/taskDesc",H5ServerUrl];
NSURL* url=[NSURL URLWithString:urlStr];
NSURLRequest *request =[NSURLRequest requestWithURL:url];
[self.contentWebView loadRequest:request];
}
//
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
}
#pragma mark - getters and setters
- (WKWebView *)contentWebView {
if (!_contentWebView) {
//
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc]init];
//
configuration.selectionGranularity = YES;
// webpr
configuration.processPool = [[WKProcessPool alloc] init];
//, jsoc(OCURL)
WKUserContentController * UserContentController = [[WKUserContentController alloc]init];
//
configuration.suppressesIncrementalRendering = NO;
//
configuration.preferences.javaScriptEnabled = YES;
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.userContentController = UserContentController;
// iOS9iOS8
if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
//
configuration.allowsAirPlayForMediaPlayback = YES;
// 线
configuration.allowsInlineMediaPlayback = YES;
// NOios8
_contentWebView.allowsBackForwardNavigationGestures = YES;
}
_contentWebView = [[WKWebView alloc] initWithFrame:CGRectMake(25, NavContentHeight+40, self.width-25*2, self.height-(NavContentHeight+40)*2-30) configuration:configuration];
_contentWebView.backgroundColor = [UIColor clearColor];
[_contentWebView addRoundedCornersWithRadius:16];
_contentWebView.opaque = NO;
//
[_contentWebView sizeToFit];
_contentWebView.scrollView.showsVerticalScrollIndicator = NO;
_contentWebView.scrollView.backgroundColor = [UIColor clearColor];
_contentWebView.scrollView.bounces = NO;
//
_contentWebView.navigationDelegate = self;
}
return _contentWebView;
}
@end