This commit is contained in:
PengGJ 2025-04-18 17:09:08 +08:00
parent b750baf0eb
commit e2902ac129
2 changed files with 212 additions and 0 deletions

View File

@ -0,0 +1,196 @@
//
// GengXinAlterView.m
// ProductApp
//
// Created by on 2025/4/10.
//
#import "GengXinAlterView.h"
#import "AppDelegate.h"
@interface GengXinAlterView ()
///
@property (nonatomic , strong) UIView *viewback;
@property (nonatomic , strong) UILabel *lbname;
///
@property (nonatomic , strong) UIButton *btdis;
///
@property (nonatomic , strong) UIView *viewV;
@property (nonatomic , strong) UILabel *lbV;
///
@property (nonatomic , strong) UIButton *btok;
///
@property (nonatomic , strong) NSString *strtitle;
@property (nonatomic , strong) NSString *strversion;
@property (nonatomic , assign) BOOL isforce;
@end
@implementation GengXinAlterView
-(id)initWithFrame:(CGRect)frame
{
if(self = [super initWithFrame:frame])
{
[self setBackgroundColor:RGBACOLOR(0, 0, 0, 0.4)];
UIView *viewback = [[UIView alloc] init];
[viewback setBackgroundColor:[UIColor whiteColor]];
[self addSubview:viewback];
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(40);
make.right.equalTo(self).offset(-40);
make.center.equalTo(self);
}];
[viewback.layer setMasksToBounds:NO];
[viewback.layer setCornerRadius:20];
[viewback setUserInteractionEnabled:YES];
_viewback = viewback;
UIImage *image = [UIImage imageNamed:@"gengxinback"];
UIImageView *imgvback = [[UIImageView alloc] init];
[imgvback setImage:image];
[viewback addSubview:imgvback];
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewback);
make.top.offset(-(UISCREEN_WIDTH-80)*image.size.height/image.size.width*148/348.0);
make.height.offset((UISCREEN_WIDTH-80)*image.size.height/image.size.width);
}];
UILabel *lbtitle = [[UILabel alloc] init];
[lbtitle setText:@"发现新版本"];
[lbtitle setTextColor:RGBCOLOR(26, 26, 26)];
[lbtitle setTextAlignment:NSTextAlignmentLeft];
[lbtitle setFont:[UIFont fontWithName:@"PingFangSC-Medium" size:18]];
[lbtitle setNumberOfLines:2];
[viewback addSubview:lbtitle];
[lbtitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(viewback);
make.top.offset(43);
}];
UILabel *lbV = [[UILabel alloc] init];
[lbV setText:@"V2.0.0"];
[lbV setTextColor:RGBCOLOR(153, 153, 153)];
[lbV setTextAlignment:NSTextAlignmentLeft];
[lbV setFont:[UIFont systemFontOfSize:12]];
[viewback addSubview:lbV];
[lbV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(lbtitle.mas_bottom).offset(10);
make.centerX.equalTo(viewback);
}];
_lbV = lbV;
UILabel *lbname = [[UILabel alloc] init];
[lbname setText:@"1、新版本"];
[lbname setTextColor:RGBACOLOR(255, 255, 255, 0.6)];
[lbname setTextAlignment:NSTextAlignmentLeft];
[lbname setFont:[UIFont systemFontOfSize:14]];
[lbname setNumberOfLines:0];
[viewback addSubview:lbname];
[lbname mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(lbV.mas_bottom).offset(12);
make.left.offset(60);
make.right.equalTo(viewback).offset(-50);
}];
_lbname = lbname;
UIButton *btok = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, (UISCREEN_WIDTH-74-80)/2.0, 40)];
[btok setTitle:@"同意并继续" forState:UIControlStateNormal];
[btok setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btok.titleLabel setFont:[UIFont systemFontOfSize:16]];
[viewback addSubview:btok];
[btok mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(viewback).offset(-26);
make.top.equalTo(lbname.mas_bottom).offset(20);
make.height.offset(40);
make.width.offset((UISCREEN_WIDTH-74-80)/2.0);
}];
[btok addTarget:self action:@selector(updataAction) forControlEvents:UIControlEventTouchUpInside];
[btok.layer setMasksToBounds:YES];
[btok.layer setCornerRadius:20];
[Tools changedView:btok colors:@[(id)RGBCOLOR(119, 140, 245).CGColor,(id)RGBCOLOR(166, 121, 244).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
_btok = btok;
UIButton *btdis = [[UIButton alloc] init];
[btdis setTitle:@"不同意" forState:UIControlStateNormal];
[btdis setTitleColor:RGBCOLOR(102, 102, 102) forState:UIControlStateNormal];
[btdis.titleLabel setFont:[UIFont systemFontOfSize:16]];
[btdis setBackgroundColor:RGBCOLOR(238, 238, 238)];
[viewback addSubview:btdis];
[btdis mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(26);
make.top.height.equalTo(btok);
make.right.equalTo(btok.mas_left).offset(-12);
}];
[btdis.layer setMasksToBounds:YES];
[btdis.layer setCornerRadius:20];
[btdis addTarget:self action:@selector(disAction) forControlEvents:UIControlEventTouchUpInside];
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(btdis).offset(19);
}];
}
return self;
}
-(void)setStrtitle:(NSString *)strtitle
{
self.lbname.text = strtitle;
///
NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
style.lineSpacing = 11;
style.lineBreakMode = NSLineBreakByTruncatingTail;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:self.lbname.text];
[attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, self.lbname.text.length)];
self.lbname.attributedText = attrString;
}
-(void)setStrversion:(NSString *)strversion
{
self.lbV.text = strversion;
// [self.viewV setHidden:YES];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [Tools changedView:self.viewV colors:@[(id)RGBCOLOR(255, 213, 108).CGColor,(id)RGBCOLOR(254, 122, 133).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
// [self.viewV setHidden:NO];
// });
}
-(void)setIsforce:(BOOL)isforce
{
self.btdis.hidden = isforce;
if(isforce)
{
[self.btok mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.offset(UISCREEN_WIDTH-80-52);
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[Tools changedView:self.btok colors:@[(id)RGBCOLOR(119, 140, 245).CGColor,(id)RGBCOLOR(166, 121, 244).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
});
}
}
// App Store
-(void)updataAction
{
[UserInfoModel shijianShangBao:0 key:@"client.pkg.update" value:@"" extra:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:AppXZUrl] options:@{} completionHandler:nil];
}
-(void)disAction
{
[UserInfoModel shijianShangBao:0 key:@"client.pkg.cancel" value:@"" extra:@""];
[self removeFromSuperview];
}
+(void)showName:(NSString *)name strversion:(NSString *)strversion isforce:(BOOL)isforce
{
GengXinAlterView *view = [[GengXinAlterView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT)];
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
view.strtitle = name;
view.strversion = strversion;
view.isforce = isforce;
[app.window addSubview:view];
}
@end

View File

@ -0,0 +1,16 @@
//
// XieYiAlterView.h
// ProductApp
//
// Created by 工作 on 2024/6/20.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XieYiAlterView : UIView
+(void)show;
@end
NS_ASSUME_NONNULL_END