123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //
- // KSNewsAlert.m
- // StudentDaya
- //
- // Created by Kyle on 2020/2/26.
- // Copyright © 2020 DayaMusic. All rights reserved.
- //
- #import "KSNewsAlert.h"
- #import "UIView+Animation.h"
- @interface KSNewsAlert ()
- @property (weak, nonatomic) IBOutlet UIImageView *newsImage;
- @property (nonatomic, copy) NewsCallback callback;
- @property (nonatomic, strong) NSString *linkUrl;
- @end
- @implementation KSNewsAlert
- + (instancetype)shareInstance {
- KSNewsAlert *view = [[[NSBundle mainBundle] loadNibNamed:@"KSNewsAlert" owner:nil options:nil] firstObject];
- view.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
- return view;
- };
- - (void)evaluateWithMessage:(NSString *)imgUrl linkUrl:(NSString *)linkUrl callbackAction:(NewsCallback)callback {
- self.linkUrl = linkUrl;
- [self.newsImage sd_setImageWithURL:[NSURL URLWithString:[imgUrl getUrlEndcodeString]] placeholderImage:[UIImage new]];
- if (callback) {
- self.callback = callback;
- }
- }
- - (void)showAlert {
- [[UIApplication sharedApplication].keyWindow addSubview:self];
- [self setPopAnimation];
- }
- - (void)showAlertInView:(UIView *)displayView {
- [displayView addSubview:self];
- [self setPopAnimation];
- }
- - (void)hiddenAction {
- [self removeFromSuperview];
- }
- - (IBAction)sureAction:(id)sender {
- if (self.callback) {
- self.callback(YES, self.linkUrl);
- }
- [self hiddenAction];
- }
- - (IBAction)cancleAction:(id)sender {
- if (self.callback) {
- self.callback(NO, self.linkUrl);
- }
- [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
|