升级弹框改版

This commit is contained in:
fengshuo
2022-12-27 11:39:37 +08:00
parent 95a13228a1
commit b2888b586b
6 changed files with 86 additions and 24 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "version_update_bg@2x.png", "filename" : "version_update_top_bg@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "version_update_bg@3x.png", "filename" : "version_update_top_bg@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -15,12 +15,19 @@
#import "TTPopup.h" #import "TTPopup.h"
@interface XPUpgradeView() @interface XPUpgradeView()
@property (nonatomic,strong) UIImageView *bgImageView; ///
@property (nonatomic,strong) UIView *contentView;
///
@property (nonatomic,strong) UIImageView *topImageView;
///
@property (nonatomic,strong) UIView *backView;
@property (nonatomic,strong) SZTextView *textView; @property (nonatomic,strong) SZTextView *textView;
/// ///
@property (nonatomic,strong) UIStackView *stackView; @property (nonatomic,strong) UIStackView *stackView;
@property (nonatomic,strong) UIButton *updateBtn; @property (nonatomic,strong) UIButton *updateBtn;
@property (nonatomic,strong) UIButton *cancelBtn; @property (nonatomic,strong) UIButton *cancelBtn;
///
@property (nonatomic,strong) UILabel *versionLabel;
@end @end
@implementation XPUpgradeView @implementation XPUpgradeView
@@ -36,37 +43,58 @@
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
[self addSubview:self.bgImageView]; [self addSubview:self.contentView];
[self.bgImageView addSubview:self.textView]; [self.contentView addSubview:self.topImageView];
[self.bgImageView addSubview:self.stackView]; [self.contentView addSubview:self.backView];
[self.topImageView addSubview:self.versionLabel];
[self.backView addSubview:self.textView];
[self.backView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.cancelBtn]; [self.stackView addArrangedSubview:self.cancelBtn];
[self.stackView addArrangedSubview:self.updateBtn]; [self.stackView addArrangedSubview:self.updateBtn];
} }
- (void)initSubViewConstraints { - (void)initSubViewConstraints {
CGFloat kwidth = (KScreenWidth - 100);
[self mas_makeConstraints:^(MASConstraintMaker *make) { [self mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(250, 311)); make.size.mas_equalTo(CGSizeMake(kwidth, 340));
}]; }];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self); make.edges.equalTo(self);
}]; }];
CGFloat kscale = 140.0 / 275.0;
[self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kwidth, kwidth * kscale));
make.top.mas_equalTo(self.contentView);
make.centerX.mas_equalTo(self.contentView);
}];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.contentView);
make.top.mas_equalTo(self.topImageView.mas_bottom);
}];
[self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.topImageView).offset(25);
make.top.mas_equalTo(self.topImageView).offset(90 * kScreenScale);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32); make.height.mas_equalTo(36);
make.centerX.mas_equalTo(self.bgImageView); make.centerX.mas_equalTo(self.contentView);
make.bottom.mas_equalTo(self.bgImageView).offset(-20); make.bottom.mas_equalTo(self.contentView).offset(-20);
}]; }];
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(106); make.width.mas_equalTo((kwidth - 11 - 16 * 2) / 2.0);
}]; }];
[self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(106); make.width.mas_equalTo(self.cancelBtn);
}]; }];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) { [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.bgImageView.mas_top).mas_offset(136); make.top.equalTo(self.topImageView.mas_bottom).mas_offset(3);
make.left.mas_equalTo(17); make.left.mas_equalTo(17);
make.right.mas_equalTo(-17); make.right.mas_equalTo(-17);
make.bottom.equalTo(self.stackView.mas_top).offset(-5); make.bottom.equalTo(self.stackView.mas_top).offset(-5);
@@ -76,7 +104,15 @@
-(void)setVersionModel:(XPVersionUpdateModel *)versionModel{ -(void)setVersionModel:(XPVersionUpdateModel *)versionModel{
_versionModel = versionModel; _versionModel = versionModel;
_textView.text = _versionModel.updateVersionDesc; if (_versionModel.updateVersionDesc) {
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:_versionModel.updateVersionDesc attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor mainTextColor]}];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 5;
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, _versionModel.updateVersionDesc.length)];
_textView.attributedText = attribute;
}
_versionLabel.text = [NSString stringWithFormat:@"V%@", _versionModel.updateVersion];
_cancelBtn.hidden = _versionModel.updateStatus == 3; _cancelBtn.hidden = _versionModel.updateStatus == 3;
} }
@@ -94,6 +130,24 @@
[TTPopup dismiss]; [TTPopup dismiss];
} }
#pragma mark - #pragma mark -
- (UIView *)contentView {
if (!_contentView) {
_contentView = [[UIView alloc] init];
_contentView.backgroundColor = [UIColor clearColor];
_contentView.layer.cornerRadius = 12;
_contentView.layer.masksToBounds = YES;
}
return _contentView;
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [UIColor whiteColor];
}
return _backView;
}
- (UIStackView *)stackView { - (UIStackView *)stackView {
if (!_stackView) { if (!_stackView) {
_stackView = [[UIStackView alloc] init]; _stackView = [[UIStackView alloc] init];
@@ -105,14 +159,14 @@
return _stackView; return _stackView;
} }
- (UIImageView *)bgImageView{ - (UIImageView *)topImageView{
if (!_bgImageView){ if (!_topImageView){
_bgImageView = [UIImageView new]; _topImageView = [UIImageView new];
_bgImageView.backgroundColor = [UIColor clearColor]; _topImageView.backgroundColor = [UIColor clearColor];
_bgImageView.userInteractionEnabled = YES; _topImageView.userInteractionEnabled = YES;
_bgImageView.image = [UIImage imageNamed:@"version_update_bg"]; _topImageView.image = [UIImage imageNamed:@"version_update_top_bg"];
} }
return _bgImageView; return _topImageView;
} }
- (SZTextView *)textView { - (SZTextView *)textView {
@@ -126,6 +180,14 @@
return _textView; return _textView;
} }
- (UILabel *)versionLabel {
if (!_versionLabel) {
_versionLabel = [[UILabel alloc] init];
_versionLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_versionLabel.textColor = [UIColor whiteColor];
}
return _versionLabel;
}
-(UIButton *)updateBtn{ -(UIButton *)updateBtn{
if (!_updateBtn){ if (!_updateBtn){
@@ -135,7 +197,7 @@
_updateBtn.titleLabel.font = [UIFont systemFontOfSize:14]; _updateBtn.titleLabel.font = [UIFont systemFontOfSize:14];
_updateBtn.titleLabel.textColor = [ThemeColor confirmButtonTextColor]; _updateBtn.titleLabel.textColor = [ThemeColor confirmButtonTextColor];
[_updateBtn setBackgroundImage:image forState:UIControlStateNormal]; [_updateBtn setBackgroundImage:image forState:UIControlStateNormal];
_updateBtn.layer.cornerRadius = 32 / 2; _updateBtn.layer.cornerRadius = 36 / 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];
} }
@@ -149,7 +211,7 @@
_cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14]; _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[_cancelBtn setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal]; [_cancelBtn setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal];
[_cancelBtn setBackgroundImage:image forState:UIControlStateNormal]; [_cancelBtn setBackgroundImage:image forState:UIControlStateNormal];
_cancelBtn.layer.cornerRadius = 32 / 2; _cancelBtn.layer.cornerRadius = 36 / 2;
_cancelBtn.layer.masksToBounds = YES; _cancelBtn.layer.masksToBounds = YES;
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside]; [_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
} }