| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //
- // KSTipsAlert.m
- // TeacherDaya
- //
- // Created by Kyle on 2021/5/21.
- // Copyright © 2021 DayaMusic. All rights reserved.
- //
- #import "KSTipsAlert.h"
- #import "UIView+Animation.h"
- @interface KSTipsAlert ()
- @property (weak, nonatomic) IBOutlet UILabel *topTitle;
- @property (weak, nonatomic) IBOutlet UILabel *descLabel;
- @property (weak, nonatomic) IBOutlet UIButton *cancleButton;
- @property (weak, nonatomic) IBOutlet UIButton *sureButton;
- @property (nonatomic, copy) TipsAlertCallback callback;
- @end
- @implementation KSTipsAlert
- + (instancetype)shareInstanceWithTitle:(NSString *)title descMessage:(NSString *)descMessage leftTitle:(NSString *)leftTitle rightTitle:(NSString *)rightTitle callback:(TipsAlertCallback)callback {
- KSTipsAlert *alertView = [[[NSBundle mainBundle] loadNibNamed:@"KSTipsAlert" owner:nil options:nil] firstObject];
- alertView.topTitle.text = title;
- alertView.descLabel.text = descMessage;
- [alertView.cancleButton setTitle:leftTitle forState:UIControlStateNormal];
- [alertView.sureButton setTitle:rightTitle forState:UIControlStateNormal];
- if (callback) {
- alertView.callback = callback;
- }
- [alertView showAlert];
- return alertView;
- }
- - (void)showAlert {
- [[NSObject getKeyWindow] addSubview:self];
- [self mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.right.mas_equalTo([NSObject getKeyWindow]);
- }];
- [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
|