资源简介

对于swift4.2的网络请求的封装。包含链式,类AFN及对moya的封装。封装的功能包含:1.一次性处理请求指示器HUD 2.一次性处理请求状态码及错误弹窗 3.登录过期自动跳转到登录页等。 4.可以处理所有接口都要使用的公共参数。

资源截图

代码片段和文件信息

//
// MBProgressHUD.m
// Version 1.1.0
// Created by Matej Bukovinski on 2.4.09.
//

#import “MBProgressHUD.h“
#import 


#ifndef kCFCoreFoundationVersionNumber_iOS_7_0
    #define kCFCoreFoundationVersionNumber_iOS_7_0 847.20
#endif

#ifndef kCFCoreFoundationVersionNumber_iOS_8_0
    #define kCFCoreFoundationVersionNumber_iOS_8_0 1129.15
#endif

#define MBMainThreadAssert() NSAssert([NSThread isMainThread] @“MBProgressHUD needs to be accessed on the main thread.“);

CGFloat const MBProgressMaxOffset = 1000000.f;

static const CGFloat MBDefaultPadding = 4.f;
static const CGFloat MBDefaultLabelFontSize = 16.f;
static const CGFloat MBDefaultDetailsLabelFontSize = 12.f;


@interface MBProgressHUD () {
    // Deprecated
    UIColor *_activityIndicatorColor;
    CGFloat _opacity;
}

@property (nonatomic assign) BOOL useAnimation;
@property (nonatomic assign getter=hasFinished) BOOL finished;
@property (nonatomic strong) UIView *indicator;
@property (nonatomic strong) NSDate *showStarted;
@property (nonatomic strong) NSArray *paddingConstraints;
@property (nonatomic strong) NSArray *bezelConstraints;
@property (nonatomic strong) UIView *topSpacer;
@property (nonatomic strong) UIView *bottomSpacer;
@property (nonatomic weak) NSTimer *graceTimer;
@property (nonatomic weak) NSTimer *minShowTimer;
@property (nonatomic weak) NSTimer *hideDelayTimer;
@property (nonatomic weak) CADisplaylink *progressobjectDisplaylink;

// Deprecated
@property (assign) BOOL taskInProgress;

@end


@interface MBProgressHUDRoundedButton : UIButton
@end


@implementation MBProgressHUD

#pragma mark - Class methods

+ (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
    MBProgressHUD *hud = [[self alloc] initWithView:view];
    hud.removeFromSuperViewOnHide = YES;
    [view addSubview:hud];
    [hud showAnimated:animated];
    return hud;
}

+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated {
    MBProgressHUD *hud = [self HUDForView:view];
    if (hud != nil) {
        hud.removeFromSuperViewOnHide = YES;
        [hud hideAnimated:animated];
        return YES;
    }
    return NO;
}

+ (MBProgressHUD *)HUDForView:(UIView *)view {
    NSEnumerator *subviewsEnum = [view.subviews reverseobjectEnumerator];
    for (UIView *subview in subviewsEnum) {
        if ([subview isKindOfClass:self]) {
            MBProgressHUD *hud = (MBProgressHUD *)subview;
            if (hud.hasFinished == NO) {
                return hud;
            }
        }
    }
    return nil;
}

#pragma mark - Lifecycle

- (void)commonInit {
    // Set default values for properties
    _animationType = MBProgressHUDAnimationFade;
    _mode = MBProgressHUDModeIndeterminate;
    _margin = 20.0f;
    _opacity = 1.f;
    _defaultMotionEffectsEnabled = YES;

    // Default color depending on the current iOS version
    BOOL isLegacy = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0;
    _contentColor = isLegacy ? [UIColor whiteColor] :

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\
     文件        6148  2018-12-25 09:06  SwiftHttpRequest-master\.DS_Store
     文件          65  2018-12-25 09:06  SwiftHttpRequest-master\.gitattributes
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\
     文件       32164  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.pbxproj
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.xcworkspace\
     文件         156  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.xcworkspace\contents.xcworkspacedata
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.xcworkspace\xcuserdata\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.xcworkspace\xcuserdata\yijin.xcuserdatad\
     文件       11122  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\project.xcworkspace\xcuserdata\yijin.xcuserdatad\UserInterfaceState.xcuserstate
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\duodiankeji.xcuserdatad\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\duodiankeji.xcuserdatad\xcschemes\
     文件         346  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\duodiankeji.xcuserdatad\xcschemes\xcschememanagement.plist
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yijin.xcuserdatad\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yijin.xcuserdatad\xcschemes\
     文件         334  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yijin.xcuserdatad\xcschemes\xcschememanagement.plist
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yj.xcuserdatad\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yj.xcuserdatad\xcschemes\
     文件        4388  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yj.xcuserdatad\xcschemes\HttpRequest.xcscheme
     文件         663  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcodeproj\xcuserdata\yj.xcuserdatad\xcschemes\xcschememanagement.plist
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\
     文件         229  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\contents.xcworkspacedata
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcshareddata\
     文件         238  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\duodiankeji.xcuserdatad\
     文件       57402  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\duodiankeji.xcuserdatad\UserInterfaceState.xcuserstate
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\yijin.xcuserdatad\
     文件       66459  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\yijin.xcuserdatad\UserInterfaceState.xcuserstate
     目录           0  2018-12-25 09:06  SwiftHttpRequest-master\HttpRequest.xcworkspace\xcuserdata\yijin.xcuserdatad\xcdebugger\
............此处省略260个文件信息

评论

共有 条评论