115 lines
2.8 KiB
Objective-C
115 lines
2.8 KiB
Objective-C
//
|
|
// XPRoomDatingWebAlertView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/1/4.
|
|
//
|
|
|
|
#import "XPRoomDatingWebAlertView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "XPMacro.h"
|
|
#import "TTPopup.h"
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
///View
|
|
#import "XPWebViewController.h"
|
|
|
|
static CGFloat const kContentAspectRatio = 2/3.f;
|
|
|
|
@interface XPRoomDatingWebAlertView ()
|
|
///导航栏
|
|
@property (nonatomic,strong) UIImageView *backImageView;
|
|
///显示webView
|
|
@property (nonatomic, strong) XPWebViewController *webVC;
|
|
///关闭按钮
|
|
@property (nonatomic, strong) UIButton *closeButton;
|
|
@end
|
|
|
|
@implementation XPRoomDatingWebAlertView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initView];
|
|
[self initContrations];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)initView {
|
|
[self addSubview:self.backImageView];
|
|
[self addSubview:self.closeButton];
|
|
[self.backImageView addSubview:self.webVC.view];
|
|
|
|
}
|
|
|
|
- (void)initContrations {
|
|
CGFloat kscale = 351/315;///宽和高的比
|
|
CGFloat height = (KScreenWidth - 60) * kscale;
|
|
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(KScreenWidth-60);
|
|
make.height.mas_equalTo(height + 55);
|
|
}];
|
|
|
|
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.top.mas_equalTo(self);
|
|
make.height.mas_equalTo(height);
|
|
}];
|
|
|
|
[self.webVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.backImageView).inset(30);
|
|
make.bottom.mas_equalTo(self.backImageView).offset(-20);
|
|
make.top.mas_equalTo(self.backImageView).offset(45);
|
|
}];
|
|
|
|
|
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(35, 35));
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(self.backImageView.mas_bottom).offset(22);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Action
|
|
- (void)didClickCloseButton {
|
|
[TTPopup dismiss];
|
|
}
|
|
|
|
#pragma mark - Lazy Load
|
|
- (void)setUrl:(NSString *)url {
|
|
if (url) {
|
|
self.webVC.url = url;
|
|
}
|
|
}
|
|
|
|
|
|
- (XPWebViewController *)webVC {
|
|
if (_webVC == nil) {
|
|
_webVC = [[XPWebViewController alloc] init];
|
|
_webVC.view.backgroundColor = UIColor.clearColor;
|
|
}
|
|
return _webVC;
|
|
}
|
|
|
|
- (UIImageView *)backImageView {
|
|
if (!_backImageView) {
|
|
_backImageView = [[UIImageView alloc] init];
|
|
_backImageView.image = [UIImage imageNamed:@"room_mode_dating_background"];
|
|
_backImageView.userInteractionEnabled = YES;
|
|
}
|
|
return _backImageView;
|
|
}
|
|
|
|
- (UIButton *)closeButton {
|
|
if (_closeButton == nil) {
|
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_closeButton setImage:[UIImage imageNamed:@"room_mode_dating_alert_close"] forState:UIControlStateNormal];
|
|
[_closeButton addTarget:self action:@selector(didClickCloseButton) forControlEvents:UIControlEventTouchUpInside];
|
|
[_closeButton enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)];
|
|
}
|
|
return _closeButton;
|
|
}
|
|
@end
|