189 lines
7.0 KiB
Objective-C
189 lines
7.0 KiB
Objective-C
//
|
|
// GengXinAlterView.m
|
|
// ProductApp
|
|
//
|
|
// Created by 工作 on 2025/4/10.
|
|
//
|
|
|
|
#import "GengXinAlterView.h"
|
|
#import "AppDelegate.h"
|
|
@interface GengXinAlterView ()
|
|
@property (nonatomic , strong) UILabel *lbname;
|
|
///
|
|
@property (nonatomic , strong) UIButton *btdis;
|
|
|
|
///
|
|
@property (nonatomic , strong) UIView *viewV;
|
|
@property (nonatomic , strong) UILabel *lbV;
|
|
|
|
|
|
///
|
|
@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:RGBCOLOR(45, 45, 45)];
|
|
[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:YES];
|
|
[viewback.layer setCornerRadius:40];
|
|
[viewback setUserInteractionEnabled:YES];
|
|
|
|
|
|
UILabel *lbtitle = [[UILabel alloc] init];
|
|
[lbtitle setText:@"发现\n新版本"];
|
|
[lbtitle setTextColor:[UIColor whiteColor]];
|
|
[lbtitle setTextAlignment:NSTextAlignmentLeft];
|
|
[lbtitle setFont:[UIFont fontWithName:@"AlimamaShuHeiTi-Bold" size:36]];
|
|
[lbtitle setNumberOfLines:2];
|
|
[viewback addSubview:lbtitle];
|
|
[lbtitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(44);
|
|
make.top.offset(43);
|
|
}];
|
|
|
|
UIView *viewV = [[UIView alloc] init];
|
|
[viewV setBackgroundColor:[UIColor clearColor]];
|
|
[viewback addSubview:viewV];
|
|
[viewV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(lbtitle).offset(4);
|
|
make.left.equalTo(lbtitle.mas_right).offset(-20);
|
|
make.height.offset(20);
|
|
}];
|
|
[viewV.layer setMasksToBounds:YES];
|
|
[viewV.layer setCornerRadius:5];
|
|
_viewV = viewV;
|
|
|
|
UILabel *lbV = [[UILabel alloc] init];
|
|
[lbV setText:@"V2.0.0"];
|
|
[lbV setTextColor:[UIColor whiteColor]];
|
|
[lbV setTextAlignment:NSTextAlignmentLeft];
|
|
[lbV setFont:[UIFont systemFontOfSize:14]];
|
|
[viewV addSubview:lbV];
|
|
[lbV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(5);
|
|
make.centerY.equalTo(viewV);
|
|
}];
|
|
_lbV = lbV;
|
|
[viewV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(lbV).offset(5);
|
|
}];
|
|
|
|
|
|
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.offset(217);
|
|
make.left.offset(60);
|
|
make.right.equalTo(viewback).offset(-50);
|
|
}];
|
|
_lbname = lbname;
|
|
|
|
|
|
UIButton *btok = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH-210, 40)];
|
|
[btok setTitle:@"立即更新" forState:UIControlStateNormal];
|
|
[btok setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[btok.titleLabel setFont:[UIFont systemFontOfSize:16]];
|
|
[btok.layer setMasksToBounds:YES];
|
|
[btok.layer setCornerRadius:10];
|
|
[viewback addSubview:btok];
|
|
[btok mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(65);
|
|
make.right.equalTo(viewback).offset(-65);
|
|
make.top.equalTo(lbname.mas_bottom).offset(38);
|
|
make.height.offset(40);
|
|
}];
|
|
[btok addTarget:self action:@selector(updataAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[btok.layer setMasksToBounds:YES];
|
|
[btok.layer setCornerRadius:6];
|
|
[Tools changedView:btok colors:@[(id)RGBCOLOR(246, 44, 108).CGColor,(id)RGBCOLOR(252, 79, 84).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
|
|
|
UIButton *btdis = [[UIButton alloc] init];
|
|
[btdis setTitle:@"稍后再说" forState:UIControlStateNormal];
|
|
[btdis setTitleColor:RGBCOLOR(102, 102, 102) forState:UIControlStateNormal];
|
|
[btdis.titleLabel setFont:[UIFont systemFontOfSize:12]];
|
|
[viewback addSubview:btdis];
|
|
[btdis mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(btok);
|
|
make.top.equalTo(btok.mas_bottom);
|
|
make.height.offset(42);
|
|
}];
|
|
[btdis setHidden:YES];
|
|
[btdis addTarget:self action:@selector(disAction) forControlEvents:UIControlEventTouchUpInside];
|
|
_btdis = btdis;
|
|
|
|
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(btdis);
|
|
}];
|
|
|
|
}
|
|
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;
|
|
}
|
|
//更新 跳转App Store
|
|
-(void)updataAction
|
|
{
|
|
[UserInfoModel shijianShangBao:0 key:@"client.pkg.update" value:@"" extra:@""];
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:AppstoreUrl] 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
|