| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- //
- // MORulesWebBaseView.m
- // MiMoLive
- //
- // Created by SuperC on 2025/9/11.
- //
- #import "MORulesWebBaseView.h"
- #import "MOWebBaseView.h"
- @interface MORulesWebBaseView ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) BigBtn *backBtn;
- @property (nonatomic, strong) UILabel *titleLab;
- @property (nonatomic, strong) MOWebBaseView *webView;
- @property (nonatomic, strong) UIButton *closeBtn;
- @end
- @implementation MORulesWebBaseView
- - (instancetype)init {
- if (self = [super init] ) {
- [self setupUI];
- }
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self){
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI{
- [self addSubview:self.bgView];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.left.right.equalTo(self);
- make.height.equalTo(@(kScaleWidth(522.0)));
- }];
-
- [self.bgView addSubview:self.titleLab];
- [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(10.0);
- make.left.equalTo(self.bgView).offset(55.0);
- make.right.equalTo(self.bgView).offset(-55.0);
- make.height.equalTo(@24.0);
- }];
-
- [self.bgView addSubview:self.backBtn];
- [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(16.0);
- make.centerY.equalTo(self.titleLab.mas_centerY);
- make.height.width.equalTo(@24.0);
- }];
-
- [self.bgView addSubview:self.webView];
- [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(44.0);
- make.left.bottom.right.equalTo(self.bgView);
- }];
-
- [self addSubview:self.closeBtn];
- [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.equalTo(self);
- make.bottom.equalTo(self.bgView.mas_top);
- }];
- }
- - (void)showRulesWebBaseView{
-
- [self updateTheBgView];
-
- self.webView.webUrl = [NSURL URLWithString:self.urlStr];
- [self.webView toLoadTheUrl];
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.x = SCREENWIDTH;
- self.bgView.frame = actionViewRect;
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.x = 0;
- weakSelf.bgView.frame = actionViewRect;
- }];
- }
- - (void)dismissRulesWebBaseView{
- //完成下移动画
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.x = SCREENWIDTH;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self removeFromSuperview];
- }];
- }
- - (void)updateTheBgView{
- if(self.isHalfView){
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.masksToBounds = YES;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
- }
-
- [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@(self.viewHieght));
- }];
- }
- #pragma mark - Lazy
- - (UIView *)bgView{
- if(!_bgView){
- _bgView = [[UIView alloc] init];
- _bgView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF"];
-
- }
- return _bgView;
- }
- - (MOWebBaseView *)webView{
- if(!_webView){
- _webView = [[MOWebBaseView alloc] init];
- }
- return _webView;
- }
- - (BigBtn *)backBtn{
- if (!_backBtn) {
- _backBtn = [[BigBtn alloc] init];
- [_backBtn setImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] forState:UIControlStateNormal];
- [_backBtn addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _backBtn;
- }
- - (void)backButtonAction{
- [self dismissRulesWebBaseView];
- }
- - (UILabel *)titleLab{
- if(!_titleLab)
- {
- _titleLab = [UILabel new];
- _titleLab.textColor = kBaseTextColor_1;
- _titleLab.textAlignment = NSTextAlignmentCenter;
- _titleLab.font = [MOTextTools poppinsMediumFont:18.0];
- _titleLab.backgroundColor = [UIColor clearColor];
- _titleLab.text = NSLocalString(@"C60017");
- }
- return _titleLab;
- }
- - (UIButton *)closeBtn{
- if(!_closeBtn){
- _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_closeBtn setTitle:@"" forState:UIControlStateNormal];
- [_closeBtn addTarget:self action:@selector(bgCloseBtnClickAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _closeBtn;
- }
- - (void)bgCloseBtnClickAction{
- [self dismissRulesWebBaseView];
- }
- @end
|