// // KSUpdateAlert.m // TeacherDaya // // Created by Kyle on 2021/5/13. // Copyright © 2021 DayaMusic. All rights reserved. // #import "KSUpdateAlert.h" #import @interface KSUpdateAlert () @property (weak, nonatomic) IBOutlet UILabel *tipsLabel; @property (weak, nonatomic) IBOutlet UILabel *descLabel; @property (weak, nonatomic) IBOutlet UIView *noforceView; @property (weak, nonatomic) IBOutlet UIView *forceView; @property (nonatomic, copy) UpdateCallback callback; @end @implementation KSUpdateAlert + (instancetype)shareInstance { KSUpdateAlert *view = [[[NSBundle mainBundle] loadNibNamed:@"KSUpdateAlert" owner:nil options:nil] firstObject]; view.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight); return view; } - (void)configWithMemo:(NSString *)memo desc:(NSString *)descMessage isForce:(BOOL)isForce callback:(UpdateCallback)callback { if (callback) { self.callback = callback; } if (isForce) { self.forceView.hidden = NO; self.noforceView.hidden = YES; } else { self.forceView.hidden = YES; self.noforceView.hidden = NO; } self.tipsLabel.text = [NSString stringWithFormat:@"V%@新版本抢先体验",memo]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:4];//调整行间距 NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:descMessage attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0f weight:UIFontWeightMedium],NSForegroundColorAttributeName:HexRGB(0x808080)}]; self.descLabel.attributedText = attrStr; } - (void)showAlert { [[UIApplication sharedApplication].keyWindow addSubview:self]; [self setPopAnimation]; } - (void)hiddenAction { [self removeFromSuperview]; } - (IBAction)cancleAction:(id)sender { if (self.callback) { self.callback(NO); } [self hiddenAction]; } - (IBAction)sureAction:(id)sender { if (self.callback) { self.callback(YES); } [self hiddenAction]; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ @end