|
|
@@ -0,0 +1,210 @@
|
|
|
+//
|
|
|
+// HWUpdateView.m
|
|
|
+// HappyWork
|
|
|
+//
|
|
|
+// Created by 张晓光 on 2019/11/6.
|
|
|
+// Copyright © 2019 张晓光. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "HWUpdateView.h"
|
|
|
+
|
|
|
+@interface HWUpdateView ()
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIView *bigView;
|
|
|
+@property (nonatomic, strong) UIImageView *icon;
|
|
|
+@property (nonatomic, strong) UIView *bgView;
|
|
|
+@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
+@property (nonatomic, strong) UILabel *detailLabel;
|
|
|
+@property (nonatomic, strong) UIView *liveView;
|
|
|
+@property (nonatomic, strong) UIButton *cancelBtn;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation HWUpdateView
|
|
|
+
|
|
|
+- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
+
|
|
|
+ if (self = [super initWithFrame:frame])
|
|
|
+ {
|
|
|
+ self.frame = [UIScreen mainScreen].bounds;
|
|
|
+ [[[[UIApplication sharedApplication] delegate] window] addSubview:self];
|
|
|
+ self.backgroundColor = [UIColor colorFromHexString:@"000000" Alpha:0.5];
|
|
|
+ [self initSubViews];
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)initSubViews {
|
|
|
+
|
|
|
+ [self addSubview:self.bigView];
|
|
|
+ [self.bigView addSubview:self.icon];
|
|
|
+ [self.bigView addSubview:self.bgView];
|
|
|
+
|
|
|
+ [self.bgView addSubview:self.titleLabel];
|
|
|
+ [self.bgView addSubview:self.detailLabel];
|
|
|
+ [self.bgView addSubview:self.liveView];
|
|
|
+ [self.bgView addSubview:self.cancelBtn];
|
|
|
+ [self.bgView addSubview:self.doneBtn];
|
|
|
+
|
|
|
+ [self.bigView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.center.equalTo(self);
|
|
|
+ make.width.mas_equalTo(HJHorizontalScale(335));
|
|
|
+ }];
|
|
|
+ [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.left.equalTo(self.bigView).offset(0);
|
|
|
+ make.right.equalTo(self.bigView).offset(0);
|
|
|
+ make.top.equalTo(self.bigView).offset(0);
|
|
|
+ make.height.mas_offset(HJHorizontalScale(161));
|
|
|
+ }];
|
|
|
+ [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.bigView).offset(0);
|
|
|
+ make.right.equalTo(self.bigView).offset(0);
|
|
|
+ make.top.equalTo(self.icon.mas_bottom).offset(0);
|
|
|
+ make.bottom.equalTo(self.bigView.mas_bottom).offset(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.centerX.equalTo(self.bgView);
|
|
|
+ make.top.equalTo(self.bgView.mas_top).offset(28);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.centerX.equalTo(self.bgView);
|
|
|
+ make.top.equalTo(self.titleLabel.mas_bottom).offset(9);
|
|
|
+ make.left.equalTo(self.icon).offset(30);
|
|
|
+ make.right.equalTo(self.icon).offset(-30);
|
|
|
+ }];
|
|
|
+ [self.liveView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.left.equalTo(self.bgView).offset(0);
|
|
|
+ make.right.equalTo(self.bgView).offset(0);
|
|
|
+ make.top.equalTo(self.detailLabel.mas_bottom).offset(70);
|
|
|
+ make.height.mas_equalTo(1);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.bgView).offset(0);
|
|
|
+ make.bottom.equalTo(self.bgView.mas_bottom).offset(0);
|
|
|
+ make.top.equalTo(self.liveView.mas_bottom).offset(0);
|
|
|
+ make.height.mas_equalTo(55);
|
|
|
+ make.right.equalTo(self.doneBtn.mas_left).offset(0);
|
|
|
+ make.width.equalTo(self.doneBtn.mas_width);
|
|
|
+ }];
|
|
|
+ [self.doneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.equalTo(self.bgView).offset(0);
|
|
|
+ make.bottom.equalTo(self.bgView.mas_bottom).offset(0);
|
|
|
+ make.top.equalTo(self.liveView.mas_bottom).offset(0);
|
|
|
+ make.height.mas_equalTo(55);
|
|
|
+ }];
|
|
|
+
|
|
|
+ self.detailLabel.text = @"1.修复目前版本的已知bug若干;\n2.修复目前版本的已知bug若干;";
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(void)removeViewFromWindow
|
|
|
+{
|
|
|
+ [UIView animateWithDuration:0.3 animations:^{
|
|
|
+ self.alpha = 0;
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ [self removeFromSuperview];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - event response
|
|
|
+
|
|
|
+- (void)cancelButtonClick:(UIButton *)btn {
|
|
|
+
|
|
|
+ [self removeViewFromWindow];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - setter and getter
|
|
|
+
|
|
|
+- (UIView *)bigView {
|
|
|
+
|
|
|
+ if (_bigView == nil)
|
|
|
+ {
|
|
|
+ _bigView = [[UIView alloc]init];
|
|
|
+ _bigView.layer.cornerRadius = 5;
|
|
|
+ _bigView.layer.masksToBounds = YES;
|
|
|
+ }
|
|
|
+ return _bigView;
|
|
|
+}
|
|
|
+- (UIView *)bgView {
|
|
|
+
|
|
|
+ if (_bgView == nil)
|
|
|
+ {
|
|
|
+ _bgView = [[UIView alloc]init];
|
|
|
+ _bgView.backgroundColor = COLOR_GRAY_F5;
|
|
|
+ }
|
|
|
+ return _bgView;
|
|
|
+}
|
|
|
+- (UIImageView *)icon {
|
|
|
+
|
|
|
+ if (_icon == nil)
|
|
|
+ {
|
|
|
+ _icon = [[UIImageView alloc]init];
|
|
|
+ _icon.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
+ _icon.image = [UIImage imageNamed:@"update_icon"];
|
|
|
+ }
|
|
|
+ return _icon;
|
|
|
+}
|
|
|
+- (UILabel *)titleLabel {
|
|
|
+
|
|
|
+ if (_titleLabel == nil)
|
|
|
+ {
|
|
|
+ _titleLabel = [[UILabel alloc]init];
|
|
|
+ _titleLabel.font = [UIFont boldSystemFontOfSize:19];
|
|
|
+ _titleLabel.textColor = COLOR_BACK_31;
|
|
|
+ _titleLabel.text = @"发现可用的新版本!";
|
|
|
+ }
|
|
|
+ return _titleLabel;
|
|
|
+}
|
|
|
+- (UILabel *)detailLabel {
|
|
|
+
|
|
|
+ if (_detailLabel == nil)
|
|
|
+ {
|
|
|
+ _detailLabel = [[UILabel alloc]init];
|
|
|
+ _detailLabel.font = [UIFont systemFontOfSize:16];
|
|
|
+ _detailLabel.textColor = COLOR_GRAY_88;
|
|
|
+ _detailLabel.numberOfLines = 0;
|
|
|
+ }
|
|
|
+ return _detailLabel;
|
|
|
+}
|
|
|
+- (UIView *)liveView {
|
|
|
+
|
|
|
+ if (_liveView == nil)
|
|
|
+ {
|
|
|
+ _liveView = [[UIView alloc]init];
|
|
|
+ _liveView.backgroundColor = COLOR_BACK_CD;
|
|
|
+ }
|
|
|
+ return _liveView;
|
|
|
+}
|
|
|
+- (UIButton *)cancelBtn {
|
|
|
+
|
|
|
+ if (_cancelBtn == nil)
|
|
|
+ {
|
|
|
+ _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [_cancelBtn setTitle:@"稍后再说" forState:UIControlStateNormal];
|
|
|
+ [_cancelBtn setTitleColor:COLOR_GRAY_88 forState:UIControlStateNormal];
|
|
|
+ _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:17];
|
|
|
+ [_cancelBtn addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ }
|
|
|
+ return _cancelBtn;
|
|
|
+}
|
|
|
+- (UIButton *)doneBtn {
|
|
|
+
|
|
|
+ if (_doneBtn == nil)
|
|
|
+ {
|
|
|
+ _doneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [_doneBtn setTitle:@"立刻升级" forState:UIControlStateNormal];
|
|
|
+ [_doneBtn setTitleColor:COLOR_GRAY_F5 forState:UIControlStateNormal];
|
|
|
+ _doneBtn.titleLabel.font = [UIFont boldSystemFontOfSize:17];
|
|
|
+ _doneBtn.backgroundColor = [UIColor colorFromHexString:@"823BFF"];
|
|
|
+ }
|
|
|
+ return _doneBtn;
|
|
|
+}
|
|
|
+@end
|