| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // KSSourceDownloadAlert.m
- // TeacherDaya
- //
- // Created by 王智 on 2024/9/13.
- // Copyright © 2024 DayaMusic. All rights reserved.
- //
- #import "KSSourceDownloadAlert.h"
- @interface KSSourceDownloadAlert ()
- @property (weak, nonatomic) IBOutlet UIView *containerView;
- @property (weak, nonatomic) IBOutlet UILabel *descLabel;
- @property (nonatomic, strong) UITapGestureRecognizer *gesture;
- @property (nonatomic, copy) DownloadSaveTipsCallback cancelCallback;
- @property (nonatomic, copy) DownloadSaveTipsCallback copyBlock;
- @property (nonatomic, copy) DownloadSaveTipsCallback sureCallback;
- @end
- @implementation KSSourceDownloadAlert
- + (instancetype)shareInstance {
- KSSourceDownloadAlert *view = [[[NSBundle mainBundle] loadNibNamed:@"KSSourceDownloadAlert" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configWithDesc:(NSString *)desc {
- if ([NSString isEmptyString:desc]) {
- desc = @"";
- }
- self.descLabel.text = desc;
- }
- - (void)actionCallbackCancel:(DownloadSaveTipsCallback)cancel copyCallback:(DownloadSaveTipsCallback)copyBlock sure:(DownloadSaveTipsCallback)sure {
- if (cancel) {
- self.cancelCallback = cancel;
- }
- if (copyBlock) {
- self.copyBlock = copyBlock;
- }
- if (sure) {
- self.sureCallback = sure;
- }
- }
- - (void)showAlert {
- UIView *displayView = [NSObject getKeyWindow];
- [displayView addSubview:self];
- [self mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.bottom.mas_equalTo(displayView);
- }];
- }
- - (IBAction)copyActipn:(id)sender {
- if (self.copyBlock) {
- self.copyBlock();
- }
- }
- - (void)removeAlert {
- [self removeFromSuperview];
- }
- - (IBAction)cancelAction:(id)sender {
- [self removeAlert];
- if (self.cancelCallback) {
- self.cancelCallback();
- }
- }
- - (IBAction)sureAction:(id)sender {
- [self removeAlert];
- if (self.sureCallback) {
- self.sureCallback();
- }
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|