修复了更新弹框的样式问题
This commit is contained in:
@@ -159,7 +159,6 @@
|
|||||||
XPVersionUpdateModel *model = [XPVersionUpdateModel modelWithDictionary:data.data];
|
XPVersionUpdateModel *model = [XPVersionUpdateModel modelWithDictionary:data.data];
|
||||||
[[self getView] getVersionUpdate:model];
|
[[self getView] getVersionUpdate:model];
|
||||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||||
NSLog(@"%@", msg);
|
|
||||||
[[self getView] getVersionUpdateFail];
|
[[self getView] getVersionUpdateFail];
|
||||||
} errorToast:NO] appVersion:appVersion os:os channel:channel];
|
} errorToast:NO] appVersion:appVersion os:os channel:channel];
|
||||||
}
|
}
|
||||||
|
@@ -299,24 +299,18 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSString *appVersion = [YYUtility appVersion];
|
NSString *appVersion = [YYUtility appVersion];
|
||||||
NSArray *appVersionList = [appVersion componentsSeparatedByString:@"."];
|
|
||||||
int appVersionNum = 0;
|
|
||||||
if(appVersionList. count == 3){
|
|
||||||
appVersionNum = [appVersionList[0]intValue] * 100 + [appVersionList[1]intValue] * 10 + [appVersionList[2]intValue];
|
|
||||||
}
|
|
||||||
NSString *updateVersion = model.updateVersion;
|
NSString *updateVersion = model.updateVersion;
|
||||||
NSArray *updateVersionList = [updateVersion componentsSeparatedByString:@"."];
|
NSComparisonResult result = [appVersion compare:updateVersion options:NSNumericSearch];
|
||||||
int updateVersionNum = 0;
|
if(result == NSOrderedSame || result == NSOrderedDescending){
|
||||||
if(updateVersionList. count == 3){
|
|
||||||
updateVersionNum = [updateVersionList[0] intValue] * 100 + [updateVersionList[1] intValue] * 10 + [updateVersionList[2] intValue];
|
|
||||||
}
|
|
||||||
if(updateVersionNum <= appVersionNum){
|
|
||||||
[self showErrorToast:@"目前已更新到最新版本"];
|
[self showErrorToast:@"目前已更新到最新版本"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XPUpgradeView *view = [[XPUpgradeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
XPUpgradeView *view = [[XPUpgradeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||||
view.versionModel = model;
|
view.versionModel = model;
|
||||||
[[UIApplication sharedApplication].keyWindow addSubview:view];
|
TTPopupService * service = [[TTPopupService alloc] init];
|
||||||
|
service.contentView = view;
|
||||||
|
service.shouldDismissOnBackgroundTouch = NO;
|
||||||
|
[TTPopup popupWithConfig:service];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Event Response
|
#pragma mark - Event Response
|
||||||
|
@@ -7,19 +7,18 @@
|
|||||||
|
|
||||||
#import "XPUpgradeView.h"
|
#import "XPUpgradeView.h"
|
||||||
#import <Masonry/Masonry.h>
|
#import <Masonry/Masonry.h>
|
||||||
|
#import <SZTextView/SZTextView.h>
|
||||||
#import "UIImage+Utils.h"
|
#import "UIImage+Utils.h"
|
||||||
#import "XPMacro.h"
|
#import "XPMacro.h"
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
#import "UIView+Corner.h"
|
#import "UIView+Corner.h"
|
||||||
|
#import "TTPopup.h"
|
||||||
|
|
||||||
@interface XPUpgradeView()
|
@interface XPUpgradeView()
|
||||||
@property (nonatomic,strong) UIImageView *bgImageView;
|
@property (nonatomic,strong) UIImageView *bgImageView;
|
||||||
@property (nonatomic,strong) UIImageView *bgheadImageView;
|
@property (nonatomic,strong) SZTextView *textView;
|
||||||
@property (nonatomic,strong) UIImageView *bgFooderImageView;
|
///容器
|
||||||
@property (nonatomic,strong) UIView *titleBgView;
|
@property (nonatomic,strong) UIStackView *stackView;
|
||||||
@property (nonatomic,strong) UILabel *titleView;
|
|
||||||
@property (nonatomic,strong) UILabel *versionView;
|
|
||||||
@property (nonatomic,strong) UILabel *textView;
|
|
||||||
@property (nonatomic,strong) UIButton *updateBtn;
|
@property (nonatomic,strong) UIButton *updateBtn;
|
||||||
@property (nonatomic,strong) UIButton *cancelBtn;
|
@property (nonatomic,strong) UIButton *cancelBtn;
|
||||||
@end
|
@end
|
||||||
@@ -39,82 +38,45 @@
|
|||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
||||||
[self addSubview:self.bgImageView];
|
[self addSubview:self.bgImageView];
|
||||||
[self.bgImageView addSubview:self.bgheadImageView];
|
|
||||||
[self.bgImageView addSubview:self.bgFooderImageView];
|
|
||||||
[self.bgImageView addSubview:self.titleBgView];
|
|
||||||
[self.bgImageView addSubview:self.titleView];
|
|
||||||
[self.bgImageView addSubview:self.versionView];
|
|
||||||
[self.bgImageView addSubview:self.textView];
|
[self.bgImageView addSubview:self.textView];
|
||||||
[self.bgImageView addSubview:self.updateBtn];
|
[self.bgImageView addSubview:self.stackView];
|
||||||
[self.bgImageView addSubview:self.cancelBtn];
|
[self.stackView addArrangedSubview:self.cancelBtn];
|
||||||
|
[self.stackView addArrangedSubview:self.updateBtn];
|
||||||
}
|
}
|
||||||
- (void)initSubViewConstraints {
|
- (void)initSubViewConstraints {
|
||||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.center.equalTo(self);
|
make.center.equalTo(self);
|
||||||
make.width.mas_equalTo(279);
|
make.width.mas_equalTo(250);
|
||||||
make.height.mas_greaterThanOrEqualTo(348);
|
make.height.mas_greaterThanOrEqualTo(311);
|
||||||
}];
|
|
||||||
[self.bgheadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.top.right.equalTo(self.bgImageView);
|
|
||||||
make.height.mas_equalTo(125);
|
|
||||||
}];
|
|
||||||
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.top.mas_equalTo(99);
|
|
||||||
make.centerX.equalTo(self.bgImageView);
|
|
||||||
make.height.mas_equalTo(24);
|
|
||||||
}];
|
|
||||||
[self.versionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.top.equalTo(self.titleView.mas_bottom).mas_offset(3);
|
|
||||||
make.height.mas_equalTo(21);
|
|
||||||
make.centerX.equalTo(self.bgImageView);
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.height.mas_equalTo(32);
|
||||||
|
make.centerX.mas_equalTo(self.bgImageView);
|
||||||
|
make.bottom.mas_equalTo(self.bgImageView).offset(-20);
|
||||||
|
}];
|
||||||
|
|
||||||
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.centerX.equalTo(self.bgImageView);
|
make.width.mas_equalTo(106);
|
||||||
make.width.mas_equalTo(50);
|
|
||||||
make.height.mas_equalTo(17);
|
|
||||||
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-18);
|
|
||||||
}];
|
}];
|
||||||
[self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.width.mas_equalTo(154);
|
make.width.mas_equalTo(106);
|
||||||
make.height.mas_equalTo(34);
|
|
||||||
make.centerX.equalTo(self.bgImageView);
|
|
||||||
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-43);
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.bgFooderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.mas_equalTo(18);
|
|
||||||
make.width.mas_equalTo(250);
|
|
||||||
make.height.mas_equalTo(227);
|
|
||||||
make.bottom.equalTo(self.bgImageView);
|
|
||||||
}];
|
|
||||||
|
|
||||||
[self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.width.equalTo(self.bgFooderImageView);
|
|
||||||
make.width.mas_equalTo(279);
|
|
||||||
make.top.equalTo(self.bgheadImageView.mas_bottom);
|
|
||||||
make.height.greaterThanOrEqualTo(@20);
|
|
||||||
make.bottom.equalTo(self.textView);
|
|
||||||
|
|
||||||
}];
|
|
||||||
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-121);
|
make.top.equalTo(self.bgImageView.mas_top).mas_offset(136);
|
||||||
make.left.mas_equalTo(39);
|
make.left.mas_equalTo(17);
|
||||||
make.right.mas_equalTo(-40);
|
make.right.mas_equalTo(-17);
|
||||||
make.top.equalTo(self.versionView.mas_bottom).mas_equalTo(9);
|
make.bottom.equalTo(self.stackView.mas_top).offset(-5);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setVersionModel:(XPVersionUpdateModel *)versionModel{
|
-(void)setVersionModel:(XPVersionUpdateModel *)versionModel{
|
||||||
_versionModel = versionModel;
|
_versionModel = versionModel;
|
||||||
_versionView.text = _versionModel.updateVersion;
|
|
||||||
_textView.text = _versionModel.updateVersionDesc;
|
_textView.text = _versionModel.updateVersionDesc;
|
||||||
_cancelBtn.hidden = _versionModel.updateStatus == 3;
|
_cancelBtn.hidden = _versionModel.updateStatus == 3;
|
||||||
if(_versionModel.updateStatus == 3){
|
|
||||||
[self.updateBtn mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-21.5);
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)updateAction{
|
-(void)updateAction{
|
||||||
@@ -122,92 +84,57 @@
|
|||||||
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
||||||
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
||||||
if(self.versionModel.updateStatus != 3){
|
if(self.versionModel.updateStatus != 3){
|
||||||
[self removeFromSuperview];
|
[TTPopup dismiss];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-(void)cancelAction{
|
-(void)cancelAction{
|
||||||
[self removeFromSuperview];
|
[TTPopup dismiss];
|
||||||
}
|
}
|
||||||
#pragma mark - 懒加载
|
#pragma mark - 懒加载
|
||||||
|
- (UIStackView *)stackView {
|
||||||
|
if (!_stackView) {
|
||||||
|
_stackView = [[UIStackView alloc] init];
|
||||||
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
||||||
|
_stackView.distribution = UIStackViewDistributionFill;
|
||||||
|
_stackView.alignment = UIStackViewAlignmentFill;
|
||||||
|
_stackView.spacing = 10;
|
||||||
|
}
|
||||||
|
return _stackView;
|
||||||
|
}
|
||||||
|
|
||||||
- (UIImageView *)bgImageView{
|
- (UIImageView *)bgImageView{
|
||||||
if (!_bgImageView){
|
if (!_bgImageView){
|
||||||
_bgImageView = [UIImageView new];
|
_bgImageView = [UIImageView new];
|
||||||
_bgImageView.backgroundColor = [UIColor clearColor];
|
_bgImageView.backgroundColor = [UIColor clearColor];
|
||||||
_bgImageView.userInteractionEnabled = YES;
|
_bgImageView.userInteractionEnabled = YES;
|
||||||
|
_bgImageView.image = [UIImage imageNamed:@"version_update_bg"];
|
||||||
}
|
}
|
||||||
return _bgImageView;
|
return _bgImageView;
|
||||||
}
|
}
|
||||||
- (UIImageView *)bgheadImageView{
|
|
||||||
if (!_bgheadImageView){
|
- (SZTextView *)textView {
|
||||||
_bgheadImageView = [UIImageView new];
|
if (!_textView) {
|
||||||
_bgheadImageView.image = [UIImage imageNamed:@"tab_upgrade_head_view"];
|
_textView = [[SZTextView alloc] init];
|
||||||
_bgheadImageView.userInteractionEnabled = YES;
|
_textView.textColor = [ThemeColor mainTextColor];
|
||||||
}
|
_textView.font = [UIFont systemFontOfSize:12];
|
||||||
return _bgheadImageView;
|
_textView.backgroundColor = [UIColor clearColor];
|
||||||
}
|
_textView.editable = NO;
|
||||||
-(UIImageView *)bgFooderImageView{
|
}
|
||||||
if (!_bgFooderImageView){
|
return _textView;
|
||||||
_bgFooderImageView = [UIImageView new];
|
|
||||||
UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFFFF),UIColorFromRGB(0xFFFFFF),UIColorFromRGB(0xE1FCFF)] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(250, 227)];
|
|
||||||
_bgFooderImageView.image = image;
|
|
||||||
_bgFooderImageView.userInteractionEnabled = YES;
|
|
||||||
[_bgFooderImageView setCornerWithLeftTopCorner:0 rightTopCorner:0 bottomLeftCorner:25 bottomRightCorner:25 size:CGSizeMake(250, 227)];
|
|
||||||
}
|
|
||||||
return _bgFooderImageView;
|
|
||||||
}
|
|
||||||
- (UIView *)titleBgView{
|
|
||||||
if (!_titleBgView){
|
|
||||||
_titleBgView = [UIView new];
|
|
||||||
_titleBgView.backgroundColor = [UIColor whiteColor];
|
|
||||||
}
|
|
||||||
return _titleBgView;
|
|
||||||
}
|
|
||||||
- (UILabel *)titleView{
|
|
||||||
if (!_titleView){
|
|
||||||
_titleView = [[UILabel alloc] init];
|
|
||||||
_titleView.text = @"";
|
|
||||||
_titleView.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold];
|
|
||||||
// _titleView.textColor = [ThemeColor inputTextColor];
|
|
||||||
// labelInitWithText:XCLocalizedString(@"XPUpgradeView0") font:[UIFont systemFontOfSize:17 weight:UIFontWeightBold] textColor:[ThemeColor inputTextColor]];
|
|
||||||
_titleView.textAlignment = NSTextAlignmentCenter;
|
|
||||||
}
|
|
||||||
return _titleView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(UILabel *)versionView{
|
|
||||||
if (!_versionView){
|
|
||||||
_versionView = [[UILabel alloc] init];
|
|
||||||
_versionView.text = @"";
|
|
||||||
_versionView.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
|
|
||||||
// _versionView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:15 weight:UIFontWeightBold] textColor:[ThemeColor inputTextColor]];
|
|
||||||
_versionView.textAlignment = NSTextAlignmentCenter;
|
|
||||||
}
|
|
||||||
return _versionView;
|
|
||||||
}
|
|
||||||
-(UILabel *)textView{
|
|
||||||
if (!_textView){
|
|
||||||
_textView = [[UILabel alloc]init];
|
|
||||||
_textView.textColor = UIColorFromRGB(0x6D6B89);
|
|
||||||
_textView.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
|
|
||||||
_textView.backgroundColor = [UIColor clearColor];
|
|
||||||
_textView.numberOfLines = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
return _textView;
|
|
||||||
}
|
|
||||||
-(UIButton *)updateBtn{
|
-(UIButton *)updateBtn{
|
||||||
if (!_updateBtn){
|
if (!_updateBtn){
|
||||||
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(154, 34)];
|
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
||||||
_updateBtn = [[UIButton alloc] init];
|
_updateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[_updateBtn setTitle:@"" forState:UIControlStateNormal];
|
[_updateBtn setTitle:@"记录更新" forState:UIControlStateNormal];
|
||||||
_updateBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
_updateBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||||
_updateBtn.titleLabel.textColor = [UIColor whiteColor];
|
_updateBtn.titleLabel.textColor = [ThemeColor confirmButtonTextColor];
|
||||||
[_updateBtn setBackgroundImage:image forState:UIControlStateNormal];
|
[_updateBtn setBackgroundImage:image forState:UIControlStateNormal];
|
||||||
// _updateBtn = [UIButton buttonInitWithText:XCLocalizedString(@"XPUpgradeView1") font:kFontRegular(14) textColor:[UIColor whiteColor] image:nil bgImage:image];
|
_updateBtn.layer.cornerRadius = 32 / 2;
|
||||||
_updateBtn.layer.cornerRadius = 34 / 2;
|
|
||||||
_updateBtn.layer.masksToBounds = YES;
|
_updateBtn.layer.masksToBounds = YES;
|
||||||
[_updateBtn addTarget:self action:@selector(updateAction) forControlEvents:UIControlEventTouchUpInside];
|
[_updateBtn addTarget:self action:@selector(updateAction) forControlEvents:UIControlEventTouchUpInside];
|
||||||
}
|
}
|
||||||
@@ -215,11 +142,14 @@
|
|||||||
}
|
}
|
||||||
-(UIButton *)cancelBtn{
|
-(UIButton *)cancelBtn{
|
||||||
if (!_cancelBtn){
|
if (!_cancelBtn){
|
||||||
_cancelBtn = [[UIButton alloc] init];
|
_cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[_cancelBtn setTitle:@"" forState:UIControlStateNormal];
|
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor],[ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
||||||
_cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
[_cancelBtn setTitle:@"下次再说" forState:UIControlStateNormal];
|
||||||
_cancelBtn.titleLabel.textColor = [ThemeColor disableButtonTextColor];
|
_cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||||
// _cancelBtn = [UIButton buttonInitWithText:XCLocalizedString(@"XPUpgradeView2") font:[UIFont systemFontOfSize:12 weight:UIFontWeightRegular] textColor:[ThemeColor disableButtonTextColor] image:nil bgImage:nil];
|
_cancelBtn.titleLabel.textColor = [ThemeColor cancelButtonTextColor];
|
||||||
|
[_cancelBtn setBackgroundImage:image forState:UIControlStateNormal];
|
||||||
|
_cancelBtn.layer.cornerRadius = 32 / 2;
|
||||||
|
_cancelBtn.layer.masksToBounds = YES;
|
||||||
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
|
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
|
||||||
}
|
}
|
||||||
return _cancelBtn;
|
return _cancelBtn;
|
||||||
|
Reference in New Issue
Block a user