Files
featherVoice/QXLive/Mine(音域)/View/钱包/QXWalletRuleView.m

152 lines
5.8 KiB
Mathematica
Raw Normal View History

2025-11-03 09:55:25 +08:00
//
// QXWalletRuleView.m
// QXLive
//
// Created by on 2025/10/31.
//
#import "QXWalletRuleView.h"
#import <WebKit/WebKit.h>
@interface QXWalletRuleView()
@property(nonatomic,strong)WKWebView *contentWebView;
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *cancelBtn;
@property (nonatomic,strong)UIButton *commitBtn;
@end
@implementation QXWalletRuleView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-ScaleWidth(350))/2.0, -self.height, ScaleWidth(350), ScaleWidth(550))];
self.bgView.backgroundColor = [UIColor whiteColor];
self.bgView.layer.masksToBounds = YES;
self.bgView.layer.cornerRadius = 16;
[self addSubview:self.bgView];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.text = QXText(@"温馨提示");
self.titleLabel.textColor = RGB16(0x333333);
[self.bgView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.bgView);
make.top.equalTo(self.bgView).offset(16);
make.height.mas_equalTo(24);
}];
self.commitBtn = [[UIButton alloc] init];
[self.commitBtn addRoundedCornersWithRadius:21];
self.commitBtn.backgroundColor = QXConfig.themeColor;
[self.commitBtn setTitle:QXText(@"我知道了") forState:(UIControlStateNormal)];
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.commitBtn addTarget:self action:@selector(cancelAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.commitBtn];
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.bgView).offset(-12);
make.height.mas_equalTo(42);
make.width.mas_equalTo(ScaleWidth(110));
make.centerX.equalTo(self.bgView);
}];
[self.bgView addSubview:self.contentWebView];
[self.contentWebView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
make.bottom.equalTo(self.commitBtn.mas_top).offset(-10);
make.left.mas_equalTo(16);
make.right.mas_equalTo(-16);
}];
[self loadData];
}
-(void)cancelAction{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kWalletRuleHide];
if (self.toWalletBlock) {
self.toWalletBlock();
}
[self hide];
}
- (void)loadData {
NSString *urlStr = [NSString stringWithFormat:@"%@api/Page/page_show?id=28",ServerUrl];
NSURL* url=[NSURL URLWithString:urlStr];
NSURLRequest *request =[NSURLRequest requestWithURL:url];
[self.contentWebView loadRequest:request];
}
-(void)showInView:(UIView *)view{
[view addSubview:self];
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.bgView.y = (SCREEN_HEIGHT-ScaleWidth(550))/2.0;
} completion:^(BOOL finished) {
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
#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, 0, self.width-25*2, self.height-(NavContentHeight+40)*2-30) configuration:configuration];
_contentWebView.backgroundColor = [UIColor clearColor];
_contentWebView.opaque = NO;
//
[_contentWebView sizeToFit];
_contentWebView.scrollView.showsVerticalScrollIndicator = NO;
_contentWebView.scrollView.backgroundColor = [UIColor clearColor];
_contentWebView.scrollView.bounces = NO;
}
return _contentWebView;
}
@end