ZJShowLogView.m 2.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
//
//  ZJShowLogView.m
//  RealEstateManagement
//
//  Created by Javen on 2017/7/25.
//  Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//

#import "ZJShowLogView.h"

@interface ZJShowLogView ()
@property (strong, nonatomic) UIView *shadow;
@property (copy, nonatomic) void (^blockCallBack)(void);
@end
@implementation ZJShowLogView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.shadow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    self.shadow.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.0];
    
    self.cornerRadius = 7;
    self.clipsToBounds = YES;
}

+ (void)showWithLog:(NSString *)log closeLog:(void (^)(void))callBack{
    ZJShowLogView *logView = [ZJShowLogView viewFromNib];
    logView.textView.text = log;
    logView.frame = CGRectMake(0, 0, kWidth, kHeight - 100);
    logView.center = kWindow.center;
    logView.transform = CGAffineTransformMakeScale(0.01, 0.01);
    logView.blockCallBack = callBack;
    [logView alert];
}


- (void)alert {
    [kWindow addSubview:self.shadow];
    [kWindow addSubview:self];
    [UIView animateWithDuration:0.5
                          delay:0
         usingSpringWithDamping:0.7
          initialSpringVelocity:1.0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
                         self.shadow.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.3];
                         self.transform = CGAffineTransformMakeScale(1, 1);
                     }
                     completion:nil];
}

- (void)cancel {
    [UIView animateWithDuration:0.5
                          delay:0
         usingSpringWithDamping:0.9
          initialSpringVelocity:1.0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
                         self.transform = CGAffineTransformMakeScale(0.01, 0.01);
                         self.shadow.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.0];
                     }
                     completion:^(BOOL finished) {
                         [self.shadow removeFromSuperview];
                         [self removeFromSuperview];
                     }];
}
- (IBAction)actionCloseLog:(id)sender {
//    kUser.isHasNetWorkDebug = NO;
    if (self.blockCallBack) {
        self.blockCallBack();
    }
    [MBProgressHUD j_textOnly:@"网络请求日志输出已关闭!"];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (IBAction)actionConfirm:(id)sender {
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:self.textView.text];
    [self cancel];
    
    
}

@end