| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //
- // MONewVersionView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/2/19.
- //
- #import "MONewVersionView.h"
- @interface MONewVersionView ()
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UIButton *updateBtn;
- @property (weak, nonatomic) IBOutlet UIButton *closeButton;
- /** 是否强制升级 */
- @property (nonatomic, assign) BOOL isStrongView;
- @property (weak, nonatomic) IBOutlet UILabel *titleLab;
- @property (weak, nonatomic) IBOutlet UITextView *contentTextView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgViewWidth;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgViewHeight;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgImageHeight;
- @property (nonatomic, copy) NSString *openUrl;
- @end
- @implementation MONewVersionView
- + (instancetype)moNewVersionView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MONewVersionView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.bgView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF"];
- self.bgView.layer.cornerRadius = 12.0;
- self.bgView.layer.masksToBounds = YES;
-
- self.updateBtn.layer.cornerRadius = 12;
- self.updateBtn.layer.masksToBounds = YES;
-
- NSArray *colorArr = @[kBaseColorLeft,kBaseColorRight];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, kScaleWidth(200), 36.0) Colors:colorArr GradientType:0];
- [self.updateBtn setBackgroundImage:image forState:UIControlStateNormal];
- [self.updateBtn setTitle:NSLocalString(@"mimo_new_version_update") forState:UIControlStateNormal];
- [self.updateBtn setFont:[MOTextTools mediumFont:14]];
-
- self.titleLab.font = [MOTextTools mediumFont:19];
- self.titleLab.textColor = [MOTools colorWithHexString:@"#FFFFFF"];
-
- [self.contentTextView setFont:[MOTextTools regularFont:15]];
- self.contentTextView.textColor = [MOTools colorWithHexString:@"#5C5E66"];
-
- self.bgViewWidth.constant = kScaleWidth(300);
- self.bgViewHeight.constant = kScaleWidth(500);
-
- self.bgImageHeight.constant = kScaleWidth(300);
-
- [self.closeButton addTarget:self action:@selector(dismissNewVersionView) forControlEvents:UIControlEventTouchUpInside];
- }
- - (void)setModel:(MOVersionModel *)model {
- _model = model;
-
- if(model.type == 2){
- self.isStrongView = YES;
- }
- self.contentTextView.text = model.desc;
- self.openUrl = model.url;
-
- self.titleLab.text = [NSString stringWithFormat:NSLocalString(@"common_version_upgrade_tip"), model.text];
- }
- - (IBAction)closeBtnClick:(id)sender {
-
- [self dismissNewVersionView];
- }
- - (IBAction)updateBtnClick:(id)sender {
-
- if(self.openUrl.length == 0){
- return;
- }
-
- if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:self.openUrl]])
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.openUrl]];
- }
- }
- - (void)showNewVersionView//界面显示动画
- {
- UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
- [keyWindow addSubview:self];
- self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT);
-
- //动画效果
- self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
- self.bgView.alpha = 0;
- [UIView animateWithDuration:0.2 animations:^
- {
- self.bgView.transform = CGAffineTransformMakeScale(1.0, 1.0);
- self.bgView.alpha = 1;
- } completion:^(BOOL finished)
- {
-
- }];
-
- }
- - (void)dismissNewVersionView
- {
- if(self.isStrongView){
- return;
- }
-
- [UIView animateWithDuration:0.2 animations:^
- {
- self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
- self.bgView.alpha = 0;
- } completion:^(BOOL finished)
- {
- if (finished)
- {
- [self removeFromSuperview];
- }
- }];
- }
- @end
|