12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // KSAudioSaveAlert.m
- // StudentDaya
- //
- // Created by 王智 on 2024/10/22.
- // Copyright © 2024 DayaMusic. All rights reserved.
- //
- #import "KSAudioSaveAlert.h"
- @interface KSAudioSaveAlert ()
- @property (weak, nonatomic) IBOutlet UIView *containerView;
- @property (weak, nonatomic) IBOutlet UILabel *descLabel;
- @property (nonatomic, strong) UITapGestureRecognizer *gesture;
- @property (nonatomic, copy) AudioSaveTipsCallback cancelCallback;
- @property (nonatomic, copy) AudioSaveTipsCallback copyBlock;
- @property (nonatomic, copy) AudioSaveTipsCallback sureCallback;
- @end
- @implementation KSAudioSaveAlert
- + (instancetype)shareInstance {
- KSAudioSaveAlert *view = [[[NSBundle mainBundle] loadNibNamed:@"KSAudioSaveAlert" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configWithDesc:(NSString *)desc {
- if ([NSString isEmptyString:desc]) {
- desc = @"";
- }
- self.descLabel.text = desc;
- }
- - (void)actionCallbackCancel:(AudioSaveTipsCallback)cancel copyCallback:(AudioSaveTipsCallback)copyBlock sure:(AudioSaveTipsCallback)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
|